Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

Have you reconsidered a computer career?


programming / comp.lang.python / latest

Re: Convert the decimal numbers expressed in a `numpy.ndarray` into a (thread)

comp.lang.python

Posted: 4 Hours 41 Minutes ago by: hongy...@gmail.com

Thank you for your above trick. I tried with the following code snippet: ``` from fractions import Fraction def strmat(m): if(np.array([m]).ndim==1): return str(Fraction(m)) else: return list(map(lambda L:strmat(L), np.array

Re: Convert the decimal numbers expressed in a `numpy.ndarray` into a matrix representing elements in fractional form (thread)

comp.lang.python

Posted: 5 Hours 58 Minutes ago by: Dennis Lee Bieber

I have no idea what 50% of those libraries are supposed to do, and am not going to install them just to try out your posted code. If you really want such help, post the MINIMUM example code the produces your problem. Explain what y

Re: Convert the decimal numbers expressed in a `numpy.ndarray` into a (thread)

comp.lang.python

Posted: 6 Hours 24 Minutes ago by: hongy...@gmail.com

I tried with the repr() method as follows, but it doesn't give any output: ``` import os,sys import numpy as np from fractions import Fraction import re from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.core import

Re: Convert the decimal numbers expressed in a `numpy.ndarray` into a (thread)

comp.lang.python

Posted: 7 Hours 15 Minutes ago by: hongy...@gmail.com

See here [1] for the related discussion. [1] https://discuss.python.org/t/convert-the-decimal-numbers-expressed-in-a-numpy-ndarray-into-a-matrix-representing-elements-in-fractional-form/15780

Re: Convert the decimal numbers expressed in a `numpy.ndarray` into a (thread)

comp.lang.python

Posted: 7 Hours 35 Minutes ago by: hongy...@gmail.com

Thank you for your explanation. I have come up with the following methods: ``` b=[[0.0, -1.0, 0.0, 0.25], [1.0, 0.0, 0.0, 0.25], [0.0, 0.0, 1.0, 0.25], [0.0, 0.0, 0.0, 1.0]] import numpy as np from fractions import Fraction import re def

Re: tail

comp.lang.python

Posted: 12 Hours 33 Minutes ago by: Marco Sulla

So I did it well to not put one in the first time. I think that after 100 posts about tail, chunks etc it was clear what that stuff was about and how to use it. Speaking about more serious things, so far I've done a test with: * a file

Re: Convert the decimal numbers expressed in a `numpy.ndarray` into a matrix representing elements in fractional form (thread)

comp.lang.python

Posted: 15 Hours 19 Minutes ago by: Dennis Lee Bieber

Printing higher level structures uses the repr() of the structure and its contents -- theoretically a form that could be used within code as a literal. If you want human-readable str() you will need to write your own output loop to do

Re: EAFP

comp.lang.python

Posted: 20 Hours 41 Minutes ago by: Peter Otten

The distinction between look-before-you-leap and easier-to-ask-forgiveness-than-permission is weaker than yo might expect. When you write filename = ... if exists(filename): with open(filename) as instream: # do stuff else

Convert the decimal numbers expressed in a `numpy.ndarray` into a

comp.lang.python

Posted: 21 Hours 43 Minutes ago by: hongy...@gmail.com

```python import os from fractions import Fraction from pymatgen.symmetry.analyzer import SpacegroupAnalyzer from pymatgen.core import Lattice, Structure, Molecule, IStructure s=IStructure.from_file(os.path.expanduser('~') + '/pymatgen-g

Python

comp.lang.python

Posted: 23 Hours 56 Minutes ago by: philippe descharmes

‌ ‌ ‌Hello,  in coding, may be is a question of transivity in this code line. Thank you. Philippe

Re: Non-deterministic set ordering

comp.lang.python

Posted: 1 Day 3 Hours ago by: Rob Cliffe

Thanks, Paul.  Question answered! Rob Cliffe On 16/05/2022 04:36, Paul Bryan wrote:

Re: Non-deterministic set ordering

comp.lang.python

Posted: 1 Day 3 Hours ago by: MRAB

Basically, Python uses hash randomisation in order to protect it against denial-of-service attacks. (Search for "PYTHONHASHSEED" in the docs.) It also applied to dicts (the code for sets was based on that for dicts), but dicts now reme

Re: Non-deterministic set ordering

comp.lang.python

Posted: 1 Day 3 Hours ago by: Paul Bryan

https://stackoverflow.com/questions/27522626/hash-function-in-python-3-3-returns-different-results-between-sessions On Mon, 2022-05-16 at 04:20 +0100, Rob Cliffe via Python-list wrote:

Re: Non-deterministic set ordering

comp.lang.python

Posted: 1 Day 3 Hours ago by: Rob Cliffe

Thanks, I can work round this behaviour. But I'm curious: where does the variability come from?  Is it deliberate (as your answer seems to imply)?  AFAIK the same code within the *same run* of a program does produce identical results.

Re: Non-deterministic set ordering

comp.lang.python

Posted: 1 Day 3 Hours ago by: Dan Stromberg

Sets are defined as unordered so that they can be hashed internally to give O(1) operations for many tasks. It wouldn't be unreasonable for sets to use a fixed-by-arbitrary ordering for a given group of set operations, but being unpredi

Non-deterministic set ordering

comp.lang.python

Posted: 1 Day 3 Hours ago by: Rob Cliffe

I was shocked to discover that when repeatedly running the following program (condensed from a "real" program) under Python 3.8.3 for p in { ('x','y'), ('y','x') }:     print(p) the output was sometimes ('y', 'x') ('x', 'y') and s

Re: Test bank for Canadian Human Resource Management 12th Canadian

comp.lang.python

Posted: 1 Day 7 Hours ago by: Michael Tingchaleun

Can someone send the file?

Re: Changing calling sequence (thread)

comp.lang.python

Posted: 1 Day 8 Hours ago by: Greg Ewing

I don't think class methods are a bad idea per se, but having them visible through instances seems unnecessary and confusing. I suspect that wasn't a deliberate design decision, but just a side effect of using a single class dict for both

Re: Changing calling sequence (thread)

comp.lang.python

Posted: 1 Day 17 Hours ago by: 2QdxY4RzWzUUiLuE

Aha. In that light, yeah, in geeral, the more stuff there is, the harder it is to get your head around it. And even if I document the class (or the module), no one makes the time to read (let alone comprehend) the document, which *shou

Re: Changing calling sequence (thread)

comp.lang.python

Posted: 2 Days 2 Hours ago by: Chris Angelico

(Confusing wording here: a class usually has far more than just __init__, but I presume you mean that the signature of __init__ is the only way to construct an object of that type.) Yeah. I would generally say, though, that any classmet

Re: Changing calling sequence (thread)

comp.lang.python

Posted: 2 Days 2 Hours ago by: dn

Allow me to extend the term "readability" to include "comprehension". Then add the statistical expectation that a class has only __init__(). Thus, assuming this is the first time (or, ... for a while) that the class is being employed, one

Mypy alternatives

comp.lang.python

Posted: 2 Days 5 Hours ago by: Dan Stromberg

Hello people. I've used Mypy and liked it in combination with MonkeyType. I've heard there are alternatives to Mypy that are faster, and I'm looking at using something like this on a 457,000 line project. Are there equivalents to MonkeyT

Re: Changing calling sequence (thread)

comp.lang.python

Posted: 2 Days 7 Hours ago by: 2QdxY4RzWzUUiLuE

Agreed. (Having proposed that approach myself (and having used it over the decades for functions, methods, procedures, constructors, ...), I also agree.) Assuming good names,¹ how can this lead to lower readability? I guess if there

Re: Changing calling sequence (thread)

comp.lang.python

Posted: 2 Days 8 Hours ago by: dn

Reading the above, it seems that the options are limited to using positional-arguments only. Because I keep tripping-over my long, grey, beard; I'm reminded that relying upon my/human memory is, um, unreliable (at least in my case). Acco

Re: Seeking deeper understanding of python equality (==)

comp.lang.python

Posted: 2 Days 12 Hours ago by: Eryk Sun

Sometimes it's simplest to directly examine an object using a native debugger (e.g. gdb in Linux; cdb/windbg in Windows). With a debugger attached to the interpreter, create two classes, one that doesn't override __eq__() and one that do

Re: Seeking deeper understanding of python equality (==)

comp.lang.python

Posted: 2 Days 18 Hours ago by: Jonathan Kaczynski

Trying some new searches, I came across slotdefs in ./Objects/typeobject.c, and those are used in the resolve_slotdups function. The comment preceding the function says, "Note that multiple names may map to the same slot (e.g. __eq__, __n

Re: .0 in name

comp.lang.python

Posted: 3 Days 1 Hour ago by: Avi Gross

You left out 3CPO, Dave. Names with numerals are not unreasonable in some circumstances. But programming languages are not a full spectrum of real life. They can have reserved words too so you may not be able to use "while" and if you c

Re: EAFP

comp.lang.python

Posted: 3 Days 1 Hour ago by: dn

Yes (once formatted for Python). If so, how to change to EAFP? Not sure if can. Let's alter the code to: foo = 0 #and def do(): return 5 / foo Then, you will expect a ZeroDivisionError exception to be raised - whereas with othe

Re: .0 in name

comp.lang.python

Posted: 3 Days 2 Hours ago by: dn

3D_position 2nd_floor_area 3M_PostIt_size 3rd_degree_polynomial 360_degree_view 12_hours_later and ??? 2_fast_2_furious

Re: .0 in name

comp.lang.python

Posted: 3 Days 5 Hours ago by: Avi Gross

Boy do I hate when I see my code mangled by the stupid AOL mailer. Not that anyone cares, but the code should be read with each line starting with the "> " prompt. If I leave lots of blank lines, it may work, but as the illustration is n

Re: Seeking deeper understanding of python equality (==)

comp.lang.python

Posted: 3 Days 6 Hours ago by: Jonathan Kaczynski

Thank you for your responses, Sam and Greg. The do_richcompare function is where my research originally took me, but I feel like I'm still missing some pieces to the puzzle. Here is my updated research since you posted your responses (I'

Re: .0 in name

comp.lang.python

Posted: 3 Days 7 Hours ago by: Paul Bryan

I had just assumed on good faith that the request to the documentation would be so that the OP could determine what is valid identifier syntax. Paul

Re: .0 in name

comp.lang.python

Posted: 3 Days 8 Hours ago by: Avi Gross

Bryan, As has been pointed out, it is very common in possibly all programming languages to not allow digits at the start of many identifiers. It makes it hard to parse for numbers which tend to start with digits. Some languages even have

Re: .0 in name

comp.lang.python

Posted: 3 Days 9 Hours ago by: Paul Bryan

The name of an attribute must be an identifier. An identifier cannot begin with a decimal number. https://docs.python.org/3/reference/lexical_analysis.html#identifiers Paul

.0 in name

comp.lang.python

Posted: 3 Days 13 Hours ago by: bryangan41

TWF5IEkga25vdyAoMSkgd2h5IGNhbiB0aGUgbmFtZSBzdGFydCB3aXRoIGEgbnVtYmVyPygyKSB3 aGVyZSBpbiB0aGUgZG9jIGlzIGl0PyE+Pj4gaW1wb3J0IHBkYj4+PiBwZGIucnVuKCcoYSBmb3Ig YSBpbiAiIiknKT4gPHN0cmluZz4oMSk8bW9kdWxlPigpKFBkYikgcy0tQ2FsbC0tPiA8c3RyaW5n PigxKTxnZ

EAFP

comp.lang.python

Posted: 3 Days 14 Hours ago by: bryangan41

SXMgdGhlIGZvbGxvd2luZyBMQllMOmZvbyA9IDEyM2lmIGZvbyA8IDIwMDrCoCDCoCBkbygpSWYg c28sIGhvdyB0byBjaGFuZ2UgdG8gRUFGUD9UaGFua3MhU2VudCBmcm9tIFNhbXN1bmcgdGFibGV0 Lg=

Re: Changing calling sequence (thread)

comp.lang.python

Posted: 3 Days 18 Hours ago by: Martin Di Paola

You probably want something like overload/multiple dispatch. I quick search on PyPI yields a 'multipledispatch' package. I never used, however. On Wed, May 11, 2022 at 08:36:26AM -0700, Tobiah wrote:

Re: Accuracy of multiprocessing.Queue.qsize before any Queue.get

comp.lang.python

Posted: 3 Days 18 Hours ago by: Martin Di Paola

If the queue was not shared to any other process, I would guess that its size is reliable. However, a plain counter could be much simpler/safer. The developer of multiprocessing.Queue, implemented size() thinking in how to share the size

Re: tail

comp.lang.python

Posted: 3 Days 19 Hours ago by: 2QdxY4RzWzUUiLuE

[...] At least with *no* documentation, the source code stands for itself. If I can execute it (whatever that entails), then I can (in theory) figure out *what* it does. I still don't what it's *supposed* to do, and therefore *canno

Re: tail

comp.lang.python

Posted: 3 Days 20 Hours ago by: Marco Sulla

You're lucky. I've seen much worse (or no one).

Re: [Solved] Re: Windows registry PermissionError

comp.lang.python

Posted: 3 Days 23 Hours ago by: Mike Dewhirst

This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------uJk9y0bBZBWXIDAprow9R070 Content-Type: multipart/mixed; boundary="------------EUuCqClFV6u02dv57WgoCOzt"; protected-headers="v1" From: Mike Dewhirst <miked@dewhirst.co

Re: [Solved] Re: Windows registry PermissionError

comp.lang.python

Posted: 4 Days ago by: Eryk Sun

Using HKEY_CURRENT_USER with RegConnectRegistryW() to access a remote registry isn't well defined and not documented as supported. If it works at all, the API probably just opens a subkey of the remote HKEY_USERS based on the string SID (

Re: [Solved] Re: Windows registry PermissionError

comp.lang.python

Posted: 4 Days ago by: Mike Dewhirst

This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------2pCgOVA077CogxmrosSnpRou Content-Type: multipart/mixed; boundary="------------WMIYaXCCt7KMMfdbQ7sNgnhY"; protected-headers="v1" From: Mike Dewhirst <miked@dewhirst.co

Re: [Solved] Re: Windows registry PermissionError

comp.lang.python

Posted: 4 Days ago by: Eryk Sun

Since self.connect() is always called, you should document that the initial hkey parameter has to be one of the following predefined key handles: HKEY_LOCAL_MACHINE HKEY_USERS HKEY_PERFORMANCE_DATA WinAPI RegConnectRegistryW(

Re: Windows registry PermissionError

comp.lang.python

Posted: 4 Days 3 Hours ago by: Eryk Sun

The access parameter is a bit mask of access rights that combine via bitwise OR (|), not via arithmetic addition. KEY_ALL_ACCESS (0x000F_003F) is a superset of KEY_WRITE (0x0002_0006): KEY_WRITE = ( READ_CONTROL |

Windows registry PermissionError

comp.lang.python

Posted: 4 Days 7 Hours ago by: Mike Dewhirst

This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------lY4wq0k70huGfuSyeSbj07zO Content-Type: multipart/mixed; boundary="------------370hm20F9mOvndmro5oyi81G"; protected-headers="v1" From: Mike Dewhirst <miked@dewhirst.co

Accuracy of multiprocessing.Queue.qsize before any Queue.get

comp.lang.python

Posted: 4 Days 7 Hours ago by: Tim Chase

The documentation says[1] Are there any circumstances under which it *is* reliable? Most germane, if I've added a bunch of items to the Queue, but not yet launched any processes removing those items from the Queue, does Queue.qsize accu

Re: tail

comp.lang.python

Posted: 4 Days 8 Hours ago by: Cameron Simpson

This is nearly the worst "specification" I have ever seen. Describe what your function _does_. Do not just send people to an arbitrary search engine to find possibly ephemeral web pages where someone has typed "man tail" and/or (if luc

Re: tail

comp.lang.python

Posted: 4 Days 8 Hours ago by: Dennis Lee Bieber

https://github.com/coreutils/coreutils/blob/master/src/tail.c Lines 567-569 (also lines 550-557 for "bytes_read" determination)

Re: tail

comp.lang.python

Posted: 4 Days 10 Hours ago by: Marco Sulla

import os _lf = b"\n" _err_n = "Parameter n must be a positive integer number" _err_chunk_size = "Parameter chunk_size must be a positive integer number" def tail(filepath, n, chunk_size0): if (n <= 0): raise ValueError(_e

Re: Changing calling sequence (thread)

comp.lang.python

Posted: 4 Days 10 Hours ago by: Michael F. Stemper

Yeah, a one-line wrapper around the original function seems a lot simpler that any of my ideas. I think that I'll even use the name from your example. Thanks to all who posted, as well as the many lurkers who support me in email.

Re: tail

comp.lang.python

Posted: 4 Days 12 Hours ago by: Stefan Ram

I am not aware of a definition of "line" above, but the PLR says: |A physical line is a sequence of characters terminated |by an end-of-line sequence. . So 10 lines should have 10 end-of-line sequences. The following try prints

Re: "py" command for Linux and Mac?

comp.lang.python

Posted: 4 Days 12 Hours ago by: De ongekruisigde

Linux by itself respects shebang lines, so you don't need a separate launcher program. Just put e.g.: #! /usr/bin/env python at the top of your Python file.

Re: "py" command for Linux and Mac?

comp.lang.python

Posted: 4 Days 12 Hours ago by: Mats Wichmann

The py command (python lanucher) respects shebang lines. https://docs.python.org/3/using/windows.html#python-launcher-for-windows

Re: tail

comp.lang.python

Posted: 4 Days 12 Hours ago by: Marco Sulla

Excuse me, you're very right. """ A function that "tails" the file. If you don't know what that means, google "man tail" filepath: the file path of the file to be "tailed" n: the numbers of lines "tailed" chunk_size: oh don't care, use

Re: "py" command for Linux and Mac?

comp.lang.python

Posted: 4 Days 13 Hours ago by: MRAB

It's called the "Python Launcher"; you'll get more helpful results if you search for that.

"py" command for Linux and Mac?

comp.lang.python

Posted: 4 Days 14 Hours ago by: Dan Stromberg

Hi folks. I heard there's a Windows-like "py" command for Linux (and Mac?). I'm finally getting to porting a particular project's Python 2.7 code to 3.x, and one of the first steps will probably be changing a lot of "python2 script.py" to

RE: Changing calling sequence (thread)

comp.lang.python

Posted: 4 Days 18 Hours ago by: David Raymond

Pj5kZWYgVGVtcHNPbmVEYXkoKmRhdGVDb21wb25lbnRzKToNCj4+ICAgIGlmIGxlbihkYXRlQ29t cG9uZW50cykgPT0gMzoNCj4+ICAgICAgICB5ZWFyLCBtb250aCwgZGF0ZSA9IGRhdGVDb21wb25l bnRzDQo+PiAgICBlbGlmIGxlbihkYXRlQ29tcG9uZW50cykgPT0gMSBhbmQgaXNpbnN0YW5jZShk YXRlQ29tc

Re: [Python-ideas] Re: New Tool Proposal

comp.lang.python

Posted: 5 Days ago by: anthony.flury

Dan, Thanks for your response, but I think PyPy will have a long way to go to make JIT generated code more efficient than hand crafted C extension. for instance PyPy will almost certainly be unable to determine if integers, floats etc

Re: tail

comp.lang.python

Posted: 5 Days 5 Hours ago by: Avi Gross

This seems to be a regular refrain where someone wants something as STANDARD in a programming language or environment and others want to keep it lean and mean or do not see THIS suggestion as particularly important or useful. Looking at

Re: tail

comp.lang.python

Posted: 5 Days 6 Hours ago by: Avi Gross

Just FYI, UNIX had a bunch of utilities that could emulate a vanilla version of tail on a command line. You can use sed, awk and quite a few others to simply show line N to the end of a file or other variations.  Of course the way many t

Re: tail

comp.lang.python

Posted: 5 Days 8 Hours ago by: Stefan Ram

Marco Sulla <Marco.Sulla.Python@gmail.com> writes:

Re: tail

comp.lang.python

Posted: 5 Days 8 Hours ago by: Dennis Lee Bieber

Especially as any Linux distribution probably includes the compiled "tail" command, so this would only be of use on Windows. Under recent Windows, one has an equivalent to "tail" IFF using PowerShell rather than the "DOS" shell. https

Re: tail

comp.lang.python

Posted: 5 Days 9 Hours ago by: Chris Angelico

If you don't care enough to benchmark it or even debug it, why should anyone else care? I'm done discussing. You think that someone else should have done this for you, but you aren't even willing to put in the effort to make this useful

Re: tail

comp.lang.python

Posted: 5 Days 9 Hours ago by: Marco Sulla

I only suppose, as I said. I should do some benchmark and some other tests, and, frankly, I don't want to. I don't want to because I'm quite sure the implementation is fast, since it reads by chunks and cache them. I'm not sure it's 100%

Re: tail

comp.lang.python

Posted: 5 Days 10 Hours ago by: Chris Angelico

Have you actually checked those three, or do you merely suppose them to be true? Still not necessary. You can simply have it in your own toolkit. Why should it be part of the core language? How much benefit would it be to anyone else? A

Re: Changing calling sequence (thread)

comp.lang.python

Posted: 5 Days 10 Hours ago by: anthony.flury

def TempsOneDayDT(date:datetime.date): return TempsOneDay(date.year, date.month, date.day) No repeat of code - just a different interface to the same functionality. ------ Original Message ------ From: "Michael F

Re: tail

comp.lang.python

Posted: 5 Days 10 Hours ago by: Marco Sulla

reads the safe Ok, I understand. This should be a Python implementation of *nix tail: import os _lf = b"\n" _err_n = "Parameter n must be a positive integer number" _err_chunk_size = "Parameter chunk_size must be a positive integer numb

Re: Changing calling sequence (thread)

comp.lang.python

Posted: 5 Days 11 Hours ago by: Grant Edwards

That would be my preference were I reading the code. It makes it quite clear that there are two completely separate signatures. I think I would be a little confused by the 2nd and 3rd values with default values — the implication would

Re: Changing calling sequence (thread)

comp.lang.python

Posted: 5 Days 11 Hours ago by: Stefan Ram

|Help on function TempsOneDay in module __main__: | |TempsOneDay(*dateComponents)

RE: Changing calling sequence (thread)

comp.lang.python

Posted: 5 Days 11 Hours ago by: David Raymond

Pj4gSSBoYXZlIGEgZnVuY3Rpb24gdGhhdCBJIHVzZSB0byByZXRyaWV2ZSBkYWlseSBkYXRhIGZy b20gYQ0KPj4gaG9tZS1icmV3IGRhdGFiYXNlLiBJdHMgY2FsbGluZyBzZXF1ZW5jZSBpczsNCj4+ IA0KPj4gZGVmIFRlbXBzT25lRGF5KCB5ZWFyLCBtb250aCwgZGF0ZSApOg0KPj4gDQo+PiBBZnRl ciB1c2luZ

Re: Changing calling sequence (thread)

comp.lang.python

Posted: 5 Days 12 Hours ago by: 2QdxY4RzWzUUiLuE

It's also the least disruptive to existing code and tests, and the most clear to readers (whether or not they're familiar with said existing code). What pieces, exactly, do you think you would repeat, especially after you extract the co

Re: Changing calling sequence (thread)

comp.lang.python

Posted: 5 Days 14 Hours ago by: Stefan Ram

In his talk "Python's Class Development Toolkit", in 2013, Raymond Hettinger elaborated on classes with more than one constructor: |Whenever you have a constructor where /everyone/ should get |their wish, you /should/ have more tha

Re: Changing calling sequence (thread)

comp.lang.python

Posted: 5 Days 15 Hours ago by: Tobiah

You could just use all keyword args: def TempsOneDay(**kwargs): if 'date' in kwargs: handle_datetime(kwargs['date']) elif 'year' in kwargs and 'month' in kwargs and 'day' in kwargs: ha

Re: Changing calling sequence (thread)

comp.lang.python

Posted: 5 Days 16 Hours ago by: Stefan Ram

I never heard something like "def ... :" called a "calling sequence". "year, month, date" is a "parameter list".

Changing calling sequence

comp.lang.python

Posted: 5 Days 17 Hours ago by: Michael F. Stemper

I have a function that I use to retrieve daily data from a home-brew database. Its calling sequence is; def TempsOneDay( year, month, date ): After using it (and its friends) for a few years, I've come to realize that there are times whe

Re: [Python-ideas] Re: New Tool Proposal

comp.lang.python

Posted: 6 Days 14 Hours ago by: Del Mervine

This might be what you are looking for? <https://mypyc.readthedocs.io/en/latest/introduction.html>

Re: [Python-ideas] Re: New Tool Proposal

comp.lang.python

Posted: 6 Days 16 Hours ago by: Dan Stromberg

Two things to say about this: 1) Sometimes abandoning a pure python module for a C extension for performance is a mistake - because Pypy is probably going to be much faster with the pure python module 2) I've had some luck using m4 to ma

Re: [Python-ideas] Re: New Tool Proposal

comp.lang.python

Posted: 6 Days 20 Hours ago by: Chris Angelico

You may still be able to take advantage of Cython as part of the process. One thing that's really cool about source code is that, fundamentally, it's all text... and Python is *great* at manipulating text files :) It might be that you can

Re: tail

comp.lang.python

Posted: 6 Days 23 Hours ago by: moi

In good software, latin-1 / ISO-8859-1 does not exist. This also the case for (and in) unicode.

Re: Instatiating module / Reusing module of command-line tool (thread)

comp.lang.python

Posted: 7 Days 4 Hours ago by: Stefan Ram

In his talk "Python's Class Development Toolkit", in 2013, Raymond Hettinger, elaborated on the close connection between modules and classes: |So, the way uh the class works is, the definitions run as |if they were in their own mod

Re: tail

comp.lang.python

Posted: 7 Days 9 Hours ago by: Alan Bawden

On Mon, 9 May 2022 at 19:53, Chris Angelico <rosuav@gmail.com> wrote: ... Nevertheless, tail is a fundamental tool in *nix. It's fast and reliable. Also the tail command can't handle different encodings? It definitely can't.

Re: tail

comp.lang.python

Posted: 7 Days 9 Hours ago by: Chris Angelico

UTF-16 ASCII seems to work fine on my system, which probably means the terminal is just ignoring all the NUL bytes. But if there's a random 0x0A anywhere, it would probably be counted as a line break. ChrisA

Re: tail

comp.lang.python

Posted: 7 Days 9 Hours ago by: Barry

POSIX tail just prints the bytes to the output that it finds between \n bytes. At no time does it need to care about encodings as that is a problem solved by the terminal software. I would not expect utf-16 to work with tail on linux sys

Re: tail

comp.lang.python

Posted: 7 Days 9 Hours ago by: Dennis Lee Bieber

Based upon https://github.com/coreutils/coreutils/blob/master/src/tail.c the ONLY thing tail looks at is single byte "\n". It does not handle other line endings, and appears to performs BINARY I/O, not text I/O. It does nothing for byte

Re: tail (thread)

comp.lang.python

Posted: 7 Days 9 Hours ago by: Barry

That is true and we’ll know to me, now show how what I said is wrong.. The os is going to DMA at least 4k, with read ahead more like 64k. So I can get that into the python memory at the same scale of time as 1 byte because it’s the

Re: tail

comp.lang.python

Posted: 7 Days 9 Hours ago by: Chris Angelico

Like most Unix programs, it handles bytes. ChrisA

Re: tail

comp.lang.python

Posted: 7 Days 11 Hours ago by: Marco Sulla

Nevertheless, tail is a fundamental tool in *nix. It's fast and reliable. Also the tail command can't handle different encodings?

Re: usb tv stick and python (thread)

comp.lang.python

Posted: 7 Days 12 Hours ago by: Dennis Lee Bieber

For the protocol... You might need to locate the source code for w_scan. Perhaps https://github.com/tbsdtv/w_scan

Re: tail

comp.lang.python

Posted: 7 Days 12 Hours ago by: 2QdxY4RzWzUUiLuE

When you're learning, and the example you tried doesn't work like it worked on the video, you probably don't know what's wrong, let alone how to correct it.

Re: tail

comp.lang.python

Posted: 7 Days 12 Hours ago by: Chris Angelico

It's still fundamentally impossible to solve this in a general way, so the best way to do things will always be to code for *your* specific use-case. That means that this doesn't belong in the stdlib or core language, but in your own tool

Re: tail

comp.lang.python

Posted: 7 Days 13 Hours ago by: Marco Sulla

Ooook, now I understand what you and Barry mean. I suppose there's no reliable way to tail a big file opened in text mode with a decent performance. Anyway, the previous-previous function I posted worked only for files opened in binary m

Re: usb tv stick and python (thread)

comp.lang.python

Posted: 7 Days 14 Hours ago by: jak

First of all, thank you for your reply. Actually I already have a handy work around to use w_scan because I have a VM with linux (ubuntu) installed. I was just looking for a python package/library that would allow me to write a wrapper ar

Re: usb tv stick and python (thread)

comp.lang.python

Posted: 7 Days 16 Hours ago by: Dennis Lee Bieber

UNTESTED... But if it works means no change to your procedures... Presuming you are using W10 or later... Activate the Windows Subsystem for Linux ([old style] Control Panel / Programs / Programs and Features... Turn Windows Featur

usb tv stick and python

comp.lang.python

Posted: 7 Days 23 Hours ago by: jak

Hello everybody, I usually use vlc to watch tv and I use the w_scan program on linux to create a file (.m3u) with the list of available channels. Unfortunately I can't find an alternative to w_scan for Windows and I was wondering if you cou

Re: tail

comp.lang.python

Posted: 8 Days 1 Hour ago by: Cameron Simpson

You're looking at IOBase, the _binary_ basis of low level common file I/O. Compare with: https://docs.python.org/3/library/io.html#io.TextIOBase.seek The positions are "opaque numbers", which means you should not ascribe any deeper mean

Re: tail

comp.lang.python

Posted: 8 Days 4 Hours ago by: Dennis Lee Bieber

You ignore that, underneath, Python is just wrapping the C API... And the documentation for C explicitly specifies that other then SEEK_END with offset 0, and SEEK_SET with offset of 0, for a text file one can only rely upon SEEK_SET us

Re: tail

comp.lang.python

Posted: 8 Days 6 Hours ago by: Greg Ewing

For some encodings, if you seek to an arbitrary byte position and then read, it may *appear* to succeed but give you complete gibberish. Your method might work for a certain subset of encodings (those that are self-synchronising) but it

Re: tail

comp.lang.python

Posted: 8 Days 9 Hours ago by: Marco Sulla

I'm not saying it's a good idea, it's only the value that I needed for my tests. Anyway, it's not a problem with big files. The problem is with files with long lines. Emh. I re-quote seek(offset, whence=SEEK_SET) Change the stream posi

Re: tail

comp.lang.python

Posted: 8 Days 10 Hours ago by: Marco Sulla

Well, my implementation is quite general now. It's not complicated and inefficient. About reliability, I can't say anything without a test case. Apart from the fact that it's very, very simple to optimize for small files: this is, IMHO,

Re: tail

comp.lang.python

Posted: 8 Days 10 Hours ago by: Barry

Try it on a very big file. What does adding 1 to a pos mean? If it’s binary it mean 1 byte further down the file but in text mode it may need to move the point 1, 2 or 3 bytes down the file. Typo I meant you have no limit. You rea

Re: tail

comp.lang.python

Posted: 8 Days 10 Hours ago by: Chris Angelico

Absolutely not. As has been stated multiple times in this thread, a fully general approach is extremely complicated, horrifically unreliable, and hopelessly inefficient. The ONLY way to make this sort of thing any good whatsoever is to kn

Re: tail

comp.lang.python

Posted: 8 Days 10 Hours ago by: Marco Sulla

Well, I tested on a little file, a list of my preferred pizzas, so.... Why? I don't see any recommendation about it in the docs: https://docs.python.org/3/library/io.html#io.IOBase.seek I explained that previously. Anyway, chunk_size

Re: tail

comp.lang.python

Posted: 8 Days 11 Hours ago by: Stefan Ram

When optimizing code, it helps to be aware of the orders of magnitude. Code that is more cache-friendly is faster, that is, code that holds data in single region of memory and that uses regular patterns of access. Chandler Carruth

Re: tail

comp.lang.python

Posted: 8 Days 11 Hours ago by: MRAB

Is it CP-1252 or ISO-8859-1 (Latin-1)?

Re: tail

comp.lang.python

Posted: 8 Days 12 Hours ago by: Barry Scott

Why use tiny chunks? You can read 4KiB as fast as 100 bytes as its typically the smaller size the file system will allocate. I tend to read on multiple of MiB as its near instant. You cannot mix POSIX API with text mode. pos is in byte

Re: tail

comp.lang.python

Posted: 8 Days 12 Hours ago by: Chris Angelico

Yeah, or sometimes, there isn't *anything* in UTF-8, and it has some sort of straight-up lie in the form of a meta tag. It's annoying. But the same logic still applies: attempt one decode (UTF-8) and if it fails, there's one fallback. Fai

Re: tail

comp.lang.python

Posted: 8 Days 12 Hours ago by: Barry Scott

There is a very common error on Windows that files and especially web pages that claim to be utf-8 are in fact CP-1252. There is logic in the HTML standards to try utf-8 and if it fails fall back to CP-1252. Its usually the left and "s

Re: tail

comp.lang.python

Posted: 8 Days 12 Hours ago by: Barry Scott

There is the posix API that and the C FILE API. I expect that the odities you about NUL chars is all about the FILE API. As far as I know its the posix API that C Python uses and it does not suffer from issues with binary files. Barry

Re: tail

comp.lang.python

Posted: 8 Days 14 Hours ago by: Marco Sulla

import os _lf = "\n" _cr = "\r" def tail(filepath, n, newline=None, encoding=None, chunk_size0): n_chunk_size = n * chunk_size pos = os.stat(filepath).st_size chunk_line_pos = -1 lines_not_found = n with open(file

Re: tail

comp.lang.python

Posted: 8 Days 22 Hours ago by: Barry

In a word no. There are cases that you just have to know the encoding you are working with.. utf-16 because you have deal with the data in 2 byte units and know if it is big endian or little endian. There will be other encoding that wi

[RELEASE] The first Python 3.11 beta (3.11.0b1) is available -

comp.lang.python

Posted: 9 Days 3 Hours ago by: Pablo Galindo Salgad

We did it, team!! After quite a bumpy release process and a bunch of last-time fixes, we have reached **beta 1** and **feature freeze**. What a ride eh? You can get the shiny new release artefacts from here: https://www.python.org/downloa

Re: tail

comp.lang.python

Posted: 9 Days 9 Hours ago by: Chris Angelico

In that case, I'd exclude ASCII from the check, and just check UTF-8, and if that fails, decode as Latin-1. Any ASCII files will decode correctly as UTF-8, and any file will decode as Latin-1. I've used this exact fallback system when de

Re: tail

comp.lang.python

Posted: 9 Days 9 Hours ago by: Stefan Ram

MRAB <python@mrabarnett.plus.com> writes:

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 9 Days 10 Hours ago by: Grant Edwards

And the "quality level" of such online forum answers seems to vary widely by subject. They're not nearly as bad for Python as they are for PHP and Javascript. Your chances of finding a correct answer to a PHP question are virtually nil.

Re: tail

comp.lang.python

Posted: 9 Days 10 Hours ago by: Chris Angelico

No, because it is only useful for stateless encodings. Any encoding which uses "shift bytes" that cause subsequent bytes to be interpreted differently will simply not work with this naive technique. Also, you're assuming that the byte(s)

Re: tail

comp.lang.python

Posted: 9 Days 11 Hours ago by: MRAB

"latin-1" will decode any sequence of bytes, so it'll never try "cp1252", nor fall back to "ascii", and falling back to "ascii" is wrong anyway because the file could contain 0x80..0xFF, which aren't supported by that encoding.

Re: tail

comp.lang.python

Posted: 9 Days 11 Hours ago by: MRAB

'.lstrip' is the wrong method to use because it treats its argument as a set of characters, so it might strip off too many characters. A better choice is '.removeprefix'. How was the file opened? If it was opened as a text file, use th

Re: tail

comp.lang.python

Posted: 9 Days 11 Hours ago by: Dennis Lee Bieber

Other than EBCDIC, <lf> and <cr> AS BYTES should appear as x0A and x0D in any of the 8-bit encodings (ASCII, ISO-8859-x, CPxxxx, UTF-8). I believe those bytes also appear in UTF-16 -- BUT, they will have a null (x00) byte associated wit

Re: tail

comp.lang.python

Posted: 9 Days 11 Hours ago by: Stefan Ram

"LF" and "CR" come from US-ASCII. It is theoretically possible that there might be some encodings out there (not for Unicode) that are not based on US-ASCII and have no LF or no CR. I have written a function that might be able

Re: tail

comp.lang.python

Posted: 9 Days 12 Hours ago by: Marco Sulla

Well, ok, but I need a generic method to get LF and CR for any encoding an user can input. Do you think that "\n".encode(encoding).lstrip("".encode(encoding)) is good for any encoding? Furthermore, is there a way to get the encoding of

Re: tail

comp.lang.python

Posted: 9 Days 13 Hours ago by: Dennis Lee Bieber

Which basically translates to: 1) Seek to beginning of file (SEEK_SET, offset 0) 2) Seek to end of file (SEEK_END, offset 0) 3) Seek to previously obtained position (SEEK_SET, offset obtained from a call to ftell(); for example, perfor

Re: tail

comp.lang.python

Posted: 9 Days 13 Hours ago by: MRAB

In the case of UTF-16, it's 2 bytes per code unit, but those 2 bytes could be little-endian or big-endian. As you didn't specify which you wanted, it defaulted to little-endian and added a BOM (U+FEFF). If you specify which endianness

Re: tail

comp.lang.python

Posted: 9 Days 13 Hours ago by: Dan Stromberg

#!/usr/local/cpython-3.10/bin/python3 """ Output the last 10 lines of a potentially-huge file. O(n). But technically so is scanning backward from the EOF. It'd be faster to use a dict, but this has the advantage of working for huge

Re: tail

comp.lang.python

Posted: 9 Days 14 Hours ago by: Marco Sulla

b'\xff\xfe\n\x00' b'\xff\xfe' b'\xff\xfea\x00\n\x00b\x00' b'\n\x00' Can I use the last trick to get the encoding of a LF or a CR in any encoding?

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 9 Days 14 Hours ago by: o1bigtenor

Hmmm - - - - fascinating discussion on language learning. I would suggest that adults CAN learn other languages. One factor that hasn't been mentioned is the musicality of the individual. I added 3 languages, to varying degrees, as an adu

Re: tail

comp.lang.python

Posted: 9 Days 16 Hours ago by: Barry

You need to handle the file in bin mode and do the handling of line endings and encodings yourself. It’s not that hard for the cases you wanted. Figure out which line ending is in use from the CR LF, LF, CR. Once you have a line decode

Re: tail

comp.lang.python

Posted: 9 Days 16 Hours ago by: Avi Gross

Marco, I think it was made clear from the start that "text" files in the classic sense have no random access method at any higher level than reading a byte at some offset from the beginning of the file, or back from the end when it has

Re: tail

comp.lang.python

Posted: 9 Days 17 Hours ago by: Stefan Ram

I think, CPython is based on C. I don't know whether Python's seek function directly calls C's fseek function, but maybe the following parts of the C standard also are relevant for Python? |Setting the file position indicator to

Re: tail

comp.lang.python

Posted: 9 Days 17 Hours ago by: Marco Sulla

So there's no way to reliably read lines in reverse in text mode using seek and read, but the only option is readlines?

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 9 Days 19 Hours ago by: Stefan Ram

Yes, I totally agree to that!

Re: [docs] Reporting a Bug

comp.lang.python

Posted: 9 Days 22 Hours ago by: anthony.flury

This is exactly as expected. Strip removes any of the characters in the passed string from both the front and the end of the string being stripped. The letter 'T' from the start of 'The meaning of life' does not appear in the word 'm

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 9 Days 22 Hours ago by: Peter J. Holzer

--utjrwkn7ohxo5kyz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2022-05-07 14:07:53 +1200, Greg Ewing wrote: I think "learning to understand the spoken language" a

Re: Instatiating module / Reusing module of command-line tool (thread)

comp.lang.python

Posted: 10 Days ago by: Cameron Simpson

Yeah, I do this quite a bit. So I might have the core class which does it all: class Thing: def __init__(self, whatever...): .... and if I'm exercising this from the command line I'll write a main function:

Re: Seeking deeper understanding of python equality (==)

comp.lang.python

Posted: 10 Days 4 Hours ago by: Greg Ewing

Generally what happens with infix operators is that the interpreter first looks for a dunder method on the left operand. If that method doesn't exist or returns NotImplemented, it then looks for a dunder method on the right operand. Ther

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 10 Days 4 Hours ago by: Greg Ewing

Such books would certainly help, but I don't think there's any substitute for actually hearing the sounds if you want to be able to understand the spoken language. In my experience, you have to listen to it for quite a while to retrain yo

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 10 Days 6 Hours ago by: Stefan Ram

[Some Unicode characters used below!] TL;DR It actually can be better to learn pronunciation from a written book than by listening to native speakers. I must add that adults have lost the ability to hear sounds in speech. In

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 10 Days 8 Hours ago by: dn

To the OP: there are many MOOCs available on the likes of the Coursera and edX platform. (rationale, below) Disclaimer: I work on courses on the edX platform (but not Python). On 06/05/2022 23.37, o1bigtenor wrote: To all: The proble

Re: tail

comp.lang.python

Posted: 10 Days 9 Hours ago by: Dennis Lee Bieber

Windows also uses <cr><lf> for the EOL marker, but Python's I/O system condenses that to just <lf> internally (for TEXT mode) -- so using the length of a string so read to compute a file position may be off-by-one for each EOL in the st

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 10 Days 10 Hours ago by: Stefan Ram

(OT) ram@zedat.fu-berlin.de (Stefan Ram) writes: For one example: in "Traité de prononciation française", 2nd edn., Paris, 1969 by Pierre Fouché, the topic of the "e muet" alone takes 50 pages!

Re: tail

comp.lang.python

Posted: 10 Days 10 Hours ago by: MRAB

Is the file UTF-8? That's a variable-width encoding, so are any of the characters > U+007F? Which OS? On Windows, it's common/normal for UTF-8 files to start with a BOM/signature, which is 3 bytes/1 codepoint.

Re: tail

comp.lang.python

Posted: 10 Days 11 Hours ago by: Marco Sulla

I have a little problem. I tried to extend the tail function, so it can read lines from the bottom of a file object opened in text mode. The problem is it does not work. It gets a starting position that is lower than the expected by 3 ch

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 10 Days 11 Hours ago by: Stefan Ram

In Le Français par la Méthode Nature by Arthur M. Jensen, there are many texts to learn French from, and under each line of text, there is another line with the pronunciation in phonetic notation. Grammar rules are also ex

pandas (in jupyter?) problem

comp.lang.python

Posted: 10 Days 11 Hours ago by: Paulo da Silva

Re: Fwd: Do projects exist to audit PyPI-hosted packages?

comp.lang.python

Posted: 10 Days 11 Hours ago by: Mats Wichmann

FWIW, there's talk of mandating MFA or appropriately scoped tokens to upload from a PyPi account to cut down on hijacking chances. As I understand it, a concern that has slowed this is that sometimes a "release" involves a ton of actual

Re: Do projects exist to audit PyPI-hosted packages?

comp.lang.python

Posted: 10 Days 13 Hours ago by: Skip Montanaro

I hadn't considered that. Some sort of authenticated connection between the source code hosting service and the PyPI user posting the package would be nice. <ramble mode="on"> Some other (only tangentially related) stuff occurs to me as

Re: Seeking deeper understanding of python equality (==)

comp.lang.python

Posted: 10 Days 13 Hours ago by: Sam Ezeh

Python/ceval.c (_PyEval_EvalFrameDefault) https://github.com/python/cpython/blob/main/Python/ceval.c#L3754-L3768 Objects/object.c (do_richcompare) https://github.com/python/cpython/blob/42fee931d055a3ef8ed31abe44603b9b2856e04d/Objects/obj

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 10 Days 14 Hours ago by: Avi Gross

This topic has rapidly shifted over way beyond Python even as the original person has not returned to participate. There are many ways to teach anything and since the classical method was to learn in person from someone using mainly sou

Fwd: Do projects exist to audit PyPI-hosted packages?

comp.lang.python

Posted: 10 Days 15 Hours ago by: Sam Ezeh

---------- Forwarded message --------- From: Sam Ezeh <sam.z.ezeh@gmail.com> Date: Fri, 6 May 2022, 15:29 Subject: Re: Do projects exist to audit PyPI-hosted packages? To: Skip Montanaro <skip.montanaro@gmail.com> I've had similar though

Do projects exist to audit PyPI-hosted packages?

comp.lang.python

Posted: 10 Days 17 Hours ago by: Skip Montanaro

I woke with a start in what amounted to the middle of the night (I really need to get about three more hours of sleep, but you'll understand why I was awake to write this). Many years ago, so as to preserve my wrists, I wrote a tool <https

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 10 Days 17 Hours ago by: 2QdxY4RzWzUUiLuE

+1 (maybe more), except that an accompanying web page or PDF only solves the problem of copying/pasting examples badly, at the expense of the cognitive load to keep track of one more thing (because it's highly unlikely that the web page

Seeking deeper understanding of python equality (==)

comp.lang.python

Posted: 10 Days 18 Hours ago by: Jonathan Kaczynski

Hi, I was recently trying to explain how python equality works and ran into a gap in my knowledge. I haven't found any good pages going beneath a surface level explanation of python equality comparison. I'll post my investigations below.

Re: Instatiating module / Reusing module of command-line tool (thread)

comp.lang.python

Posted: 10 Days 18 Hours ago by: Loris Bennett

So if I have a module which relies on having internal data being set from outside, then, even though the program only ever has one instance of the module, different runs, say test and production, would require different internal data and

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 10 Days 19 Hours ago by: o1bigtenor

As we're now discussing tutorial methods - - - - On Thu, May 5, 2022 at 8:57 PM Chris Angelico <rosuav@gmail.com> wrote: Respectfully - - - I would disagree. FreeCAD is a mind bogglingly complex architecture (a lumping together of a lot

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 11 Days 4 Hours ago by: Chris Angelico

Video tutorials make GREAT sense for learning complicated programs like Adobe PhotoShop or some 3D game design engines, because (a) most of what you need is in the menus somewhere, but it's hard to find; (b) you can aim the tutorial at a

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 11 Days 6 Hours ago by: Grant Edwards

I've always been utterly baffled by video tutorials for programming. There must be people who prefer that format, but it seems like absolutely the worst possible option for me. You can't cut/paste snippets from the examples. You have to

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 11 Days 6 Hours ago by: Avi Gross

Before more people reply to this user, I note I have not seen them reply back to the list about any questions or comments others have taken the time to provide. My warning bells go off when I see patterns and there was a similar request f

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 11 Days 12 Hours ago by: Mats Wichmann

If you know what kinds of learning experiences work best for you, that might help. For some people, books, or written tutorials are effective. For some, it's just dive in and start doing projects, referring to, say, StackOverflow when y

RE: Python/New/Learn (thread)

comp.lang.python

Posted: 11 Days 14 Hours ago by: Schachner, Joseph

QnV5IHRoZSBib29rICJQeXRob24gMTAxIiBhbmQgZG8gdGhlIGV4YW1wbGVzLiAgV2hlbiB5b3Un cmUgZG9uZSB3aXRoIHRoYXQgYnV5IHRoZSBib29rICJQeXRob24gMjAxIiBhbmQgc3R1ZHkgaXQu ICBUaGVyZSBpcyBtdWNoIG1vcmUgdGhhbiBpcyBpbiBib3RoIHRob3NlIGJvb2tzIHRoYXQgeW91 IGNvdWxkI

Re: ANN: Dogelog Player 0.9.8 (thread)

comp.lang.python

Posted: 11 Days 23 Hours ago by: Mostowski Collapse

?- listing. It then gives: p(A, B) :- \+ q(A, _), A = C, r(C, B). No singleton warning. And recently a little better listing with multiline pretty printing.

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 11 Days 23 Hours ago by: Alan Gauld

Do you know any other programming languages? That makes a huge difference in what you should start with! Others have already made recommendations. I'll add that there is a dedicated python ttutor list for those just learning to ask que

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 12 Days 3 Hours ago by: Avi Gross

I agree Chris that the Ukrainian Python Books are daunting as I barely started learning that language now even though my early years were just a few miles away and I might even have relatives still there! But as has been pointed out, su

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 12 Days 3 Hours ago by: Chris Angelico

Being helpful is great, it's just that being brief can leave it as an incredibly scary-looking list :) If you want to recommend a couple of specific books, I think that would be a lot more helpful. ChrisA

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 12 Days 3 Hours ago by: Avi Gross

Chris, It was an extremely open-ended question to a forum where most of the readers are more advanced, at least I think. My library has oodles of Python Books for free to borrow on paper and return and I have read many of them. There ar

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 12 Days 3 Hours ago by: Dan Stromberg

https://wiki.python.org/moin/BeginnersGuide/Programmers If you don't: https://wiki.python.org/moin/BeginnersGuide/NonProgrammers On Wed, May 4, 2022 at 7:49 PM Patrick 0511 <killerkomando12@gmail.com> wrote:

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 12 Days 3 Hours ago by: Chris Angelico

That's an incredibly daunting list, and not something I'd overly strongly recommend, but yes, if you want to get a dead-tree or e-book to read, there are quite a lot of options available. ChrisA

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 12 Days 3 Hours ago by: Avi Gross

https://wiki.python.org/moin/PythonBooks -----Original Message----- From: Patrick 0511 <killerkomando12@gmail.com> To: python-list@python.org Sent: Wed, May 4, 2022 9:36 pm Subject: Python/New/Learn Hello, I'm completely new here and don

Re: Python/New/Learn (thread)

comp.lang.python

Posted: 12 Days 3 Hours ago by: Chris Angelico

I'd start right here with the tutorial! https://docs.python.org/3/tutorial/ Most important thing is: play around. Have fun. Explore! You can't really go all that far wrong, so don't be afraid to try things, even "silly" things that "don

Python/New/Learn

comp.lang.python

Posted: 12 Days 5 Hours ago by: Patrick 0511

Hello, I'm completely new here and don't know anything about python. Can someone tell me how best to start? So what things should I learn first?

Re: Difference in Setup Between Windows 10 Running Python 3.9 and

comp.lang.python

Posted: 13 Days 9 Hours ago by: Eryk Sun

When running a command at startup, it's best to use the full path of the application and the full path of any files passed on the command line. For example, run something like the following: "path\to\pythonw.exe" "path\to\AIG.py" Th

python 3.9.12 and python 3.10

comp.lang.python

Posted: 13 Days 11 Hours ago by: Dave Francis

Date: Tue, 3 May 2022 19:59:08 +0100 Subject: python 3.9.12 and python 3.10 I installed 3.9 and am able to enter simple code which runs. If I type an error I can highlight it but cannot copy or delete it. I looked for help & found 3.10 and

Re: Match.groupdict: Meaning of default argument? (thread)

comp.lang.python

Posted: 13 Days 13 Hours ago by: Julio Di Egidio

P.S. I don't see Stefan's posts, and I doubt he sees mine... Julio

Re: Match.groupdict: Meaning of default argument? (thread)

comp.lang.python

Posted: 13 Days 13 Hours ago by: Julio Di Egidio

Yes, I am missing the meaning of the parameter in the call to groupdict. <https://docs.python.org/2.7/library/re.html#re.MatchObject.groupdict> And then Stefan's solution makes sense, as it's the default for the *non-optional* parts that

Re: Match.groupdict: Meaning of default argument? (thread)

comp.lang.python

Posted: 13 Days 13 Hours ago by: Julio Di Egidio

Stefan's "fix" makes it fail if there is not at least one digit in that position. And not only I don't se how that is in fact a fix, nor I still can guess where the string '0' is supposed to originate from in case we do not have the days

Re: [winreg] How to access "(Default)" key value? (thread)

comp.lang.python

Posted: 13 Days 14 Hours ago by: MRAB

Use 'QueryValue' with an empty string: value = winreg.QueryValue(key, "") or None: value = winreg.QueryValue(key, None)

Re: Match.groupdict: Meaning of default argument? (thread)

comp.lang.python

Posted: 13 Days 16 Hours ago by: Loris Bennett

I am not sure what you are trying to tell me. I wasn't expecting anything other than strings. The problem was, as Stefan helped me to understand, that I misunderstood what 'participating in the match' means. Cheers, Loris

Re: Match.groupdict: Meaning of default argument? (thread)

comp.lang.python

Posted: 13 Days 18 Hours ago by: Loris Bennett

What I actually need is ((?P<days>\d+)(-?))?(?P<hours>\d\d):(?P<minutes>\d\d):(?P<seconds>\d\d) so that I can match both 99-11:22:33 and 11:22:33 and have 'days' be '0' in the later case. Thanks for pointing me in the righ

Re: Match.groupdict: Meaning of default argument? (thread)

comp.lang.python

Posted: 13 Days 19 Hours ago by: Loris Bennett

Ah, thanks. I was misunderstanding the meaning of 'participate'. Cheers, Loris

[winreg] How to access "(Default)" key value?

comp.lang.python

Posted: 13 Days 21 Hours ago by: Nicolas Formichella

Hello, I am encountering an issue with winreg, I can't figure out how to read the "(Default)" of a registry value ``` def get_chrome_version() -> str: with winreg.ConnectRegistry(None, winreg.HKEY_CURRENT_USER) as registry: w

Re: new sorting algorithm

comp.lang.python

Posted: 14 Days 4 Hours ago by: Dan Stromberg

Median-of-3 helps, but it's still possible to construct inputs that make quicksort break down to an O(n^2) algorithm in the worst case. These inputs are much less common than sorting an already sorted, or reverse-sorted list.

Re: tail

comp.lang.python

Posted: 14 Days 11 Hours ago by: Marco Sulla

It's the same from py 3.3 I think it's correct. The last line in this case is an empty bytes. Yes, I was not very happy to duplicate the code... I have to think about it. Thank you ^^

Re: Regarding inability of Python Module Winsound to produce beep in decimal frequency (thread)

comp.lang.python

Posted: 14 Days 11 Hours ago by: Stefan Ram

Thanks for this very instructive example! I wondered whether it is possible to play a melody this way and extended your example. (The program allocates large buffers, which might lead to problems on systems which do not have more

Re: tail (thread)

comp.lang.python

Posted: 14 Days 11 Hours ago by: Marco Sulla

######## readline(size=- 1, /) Read and return one line from the stream. If size is specified, at most size bytes will be read. The line terminator is always b'\n' for binary files; for text files, the newline argument to open() can be

Re: new sorting algorithm

comp.lang.python

Posted: 14 Days 11 Hours ago by: Mats Wichmann

A quick read might be in order then... https://en.wikipedia.org/wiki/Timsort

Re: tail (thread)

comp.lang.python

Posted: 14 Days 12 Hours ago by: Chris Angelico

No, because those are Unicode characters. How they're encoded may affect the bytes you see, but those are code point values after decoding. ChrisA

Re: tail (thread)

comp.lang.python

Posted: 14 Days 12 Hours ago by: Marco Sulla

Should I suppose that other encodings may have more line ending chars?

Re: error of opening Python

comp.lang.python

Posted: 14 Days 12 Hours ago by: ARRYAN SINHA (RA1811

how do I open this file

Re: Fwd: Python Question re Executing a Script (dn)

comp.lang.python

Posted: 14 Days 13 Hours ago by: MRAB

[snip] FTR, I've already posted the suggestion to try the Python Launcher "pyw", and the OP replied off-list that it worked.

Re: Fwd: Python Question re Executing a Script (dn)

comp.lang.python

Posted: 14 Days 14 Hours ago by: Dennis Lee Bieber

Not really -- at least from my viewpoint there is not enough information to perform any diagnoses... Other than to recommend that, if the OP initially posted to the list/newsgroup, they should ensure any replies also go to the same (I d

Re: Difference in Setup Between Windows 10 Running Python 3.9 and Windows 11 Running Python 3.10 (thread)

comp.lang.python

Posted: 14 Days 16 Hours ago by: Stefan Ram

When you use "pythonw", it's possible that some messages that would otherwise have been printed to the console do not become visible. So, you might use "python" for debugging. It is possible that your program runs, but under "pyth

Re: new sorting algorithm

comp.lang.python

Posted: 14 Days 17 Hours ago by: charles hottel

Some versions of Quicksort switch over to Straight Insertion Sort when the partitions become small enough. The correct size will vary depending on the hardware. I have not kept up with the latest improvements and I am not familiar wit

Re: tail (thread)

comp.lang.python

Posted: 14 Days 18 Hours ago by: Stefan Ram

For their own applications, people are free to separate textual data records in any way they like. What I wrote, I took from the Wikipedia, which says in the article "Newline": |The Unicode standard defines a number of characters t

Re: new sorting algorithm

comp.lang.python

Posted: 14 Days 21 Hours ago by: jan

Hi, well, so it won't be pathologically slow Just to be clear because I've wondered but haven't looked into it, we know naive quicksorting of already-sorted data is pathalogical, but median-of-3 is known to fix this pathology? cheers j

Fwd: Python Question re Executing a Script (dn)

comp.lang.python

Posted: 14 Days 22 Hours ago by: dn

This is a multi-part message in MIME format. --------------FJJNY69VlfgZbSZ904Vvs7xN Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Perhaps an MS-Win user can help the OP, please? -- Regards, =dn --------------FJJ

Re: tail (thread)

comp.lang.python

Posted: 15 Days 4 Hours ago by: Chris Angelico

Yep - and there's also a distinction between "first byte of multi-byte character" and "continuation byte, keep scanning backwards". So you're guaranteed to be able to resynchronize. (If you know whether it's little-endian or big-endian,

Re: Difference in Setup Between Windows 10 Running Python 3.9 and

comp.lang.python

Posted: 15 Days 4 Hours ago by: MRAB

The problem is probably that the Python folder isn't in Windows' search path, but the recommended thing to do nowadays on Windows is to use the Python Launcher "py.exe" (or "pyw.exe" for no console window) instead: pyw AIG.py

Difference in Setup Between Windows 10 Running Python 3.9 and Windows

comp.lang.python

Posted: 15 Days 4 Hours ago by: Brent Hunter

Hello, I was recently running a Windows 10 machine Python 3.9. I simply created a batch file titled "Start-AIG.bat" which simply contained the following: "pythonw AIG.py". It started a python program titled "AIG.py" and the Python dial

Re: tail (thread)

comp.lang.python

Posted: 15 Days 4 Hours ago by: Cameron Simpson

Aye. Design festure enabling easy resync-to-char-boundary at an arbitrary point in the file. I disagree. Maybe for printing things. But textual data records? I would hope to end them with NL, and only NL (code 10). Cheers, Cameron Si

Re: new sorting algorithm

comp.lang.python

Posted: 15 Days 7 Hours ago by: Chris Angelico

The median-of-three partitioning technique makes that work reasonably well, so it won't be pathologically slow. It's hardly Quicksort's best feature, but it could easily be a lot worse. I'd have to check, but I think it still manages to b

Re: tail

comp.lang.python

Posted: 15 Days 7 Hours ago by: Chris Angelico

Most absolutely not. "Unicode" isn't an encoding, but of the Unicode Transformation Formats and Universal Character Set encodings, most don't make that guarantee: * UTF-8 does, as mentioned. It sacrifices some efficiency and consistency

Re: tail

comp.lang.python

Posted: 15 Days 7 Hours ago by: Stefan Ram

It seems in UTF-8, when a value is above U+007F, it will be encoded with bytes that always have their high bit set. But Unicode has NEL "Next Line" U+0085 and other values that conforming applications should recognize as line ter

Re: new sorting algorithm

comp.lang.python

Posted: 15 Days 7 Hours ago by: Dan Stromberg

You seem to be of the impression that nearly-sorted data isn't an uphill battle with a straightforward quicksort. I'm having a hard time convincing myself of that.

Re: tail

comp.lang.python

Posted: 15 Days 7 Hours ago by: Dan Stromberg

Scanning backward for a byte == 10 in ASCII or ISO-8859 seems fine. But what about Unicode? Are all 10 bytes newlines in Unicode encodings? If not, and you have a huge file to reverse, it might be better to use a temporary file.

Re: tail

comp.lang.python

Posted: 15 Days 8 Hours ago by: Cameron Simpson

[...] I think you want os.fstat(). I was wondering about the iter, but this makes sense. Alternatively you could put a range check in the for-loop. Normal text file _end_ in a newline. I'd expect this to stop immediately at the end

Re: new sorting algorithm

comp.lang.python

Posted: 15 Days 12 Hours ago by: Chris Angelico

Hmm, actually TimSort *does* exceed the speed of quicksort for a lot of real-world data. For instance, if you take a large sorted list, append a handful of (unsorted) items to it, and then sort the list, TimSort can take advantage of the

Re: new sorting algorithm

comp.lang.python

Posted: 15 Days 12 Hours ago by: Dan Stromberg

This probably should start out as a module on Pypi. Is the sorting stable? Python guarantees that. On Sun, May 1, 2022 at 8:53 AM Nas Bayedil <nbayedil@gmail.com> wrote:

Re: new sorting algorithm

comp.lang.python

Posted: 15 Days 13 Hours ago by: Marco Sulla

I suppose you should write to python-dev@python.org , or in https://discuss.python.org/ under the section Core development

Re: tail

comp.lang.python

Posted: 15 Days 13 Hours ago by: Marco Sulla

Something like this is OK? import os def tail(f): chunk_size = 100 size = os.stat(f.fileno()).st_size positions = iter(range(size, -1, -chunk_size)) next(positions) chunk_line_pos = -1 pos = 0 for pos in po

new sorting algorithm

comp.lang.python

Posted: 15 Days 17 Hours ago by: Nas Bayedil

*Dear, Sir/Madam* Let me first tell you briefly who we are and where we are from, what we do. My name is Nas (full name Nasipa Bayedil) from Kazakhstan. In December 2020, we registered a company online in Dover, Delaware, the United St

Re: Python Question re Executing a Script

comp.lang.python

Posted: 16 Days 4 Hours ago by: Mike Dewhirst

This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------mV4ITibEF7iWaezqP5HjuXzU Content-Type: multipart/mixed; boundary="------------LnBvgYTLPzcYdc30xawC6i3D"; protected-headers="v1" From: Mike Dewhirst <miked@dewhirst.co

Re: Python Question re Executing a Script

comp.lang.python

Posted: 16 Days 5 Hours ago by: dn

Please start with https://docs.python.org/3/using/windows.html

Re: Python Question re Executing a Script

comp.lang.python

Posted: 16 Days 7 Hours ago by: Dennis Lee Bieber

ONE: that path indicates that you installed Python "for current user only". TWO: that is the path for the short cut entry that shows up on the Windows "Start Menu" (whatever that looks like on Win11). It is NOT a location for user scr

Re: Python Question re Executing a Script (thread)

comp.lang.python

Posted: 16 Days 7 Hours ago by: Stefan Ram

The same way a python script that is located in other directories. Either on the command line via "py <path to script>", where <path to script> stands for the pathname of the script file, or by opening the script in IDLE and then

Python Question re Executing a Script

comp.lang.python

Posted: 16 Days 8 Hours ago by: Brent Hunter

Hello, I just purchased a new Windows 11 computer and installed Python 3.10.4 (64 bit). I can't figure out from your documentation, how do I: 1. Run a python script that is located in the same directory ( C:\Users\Brent\AppData\Roam

Re: Printing Unicode strings in a list

comp.lang.python

Posted: 16 Days 16 Hours ago by: Chris Angelico

Yes, for compatibility reasons. It wasn't accepted in Python 3.0, but 3.3 re-added it to make porting easier. It doesn't do anything. ChrisA

Re: Printing Unicode strings in a list

comp.lang.python

Posted: 16 Days 16 Hours ago by: Vlastimil Brom

Hi, I'm not sure, whether I am not misunderstanding the 4th question or the answers to it (it is not clear to me, whether the focus is on character printing or the quotation marks...); in either case, in python3 the character glyphs are p

Re: Match.groupdict: Meaning of default argument? (thread)

comp.lang.python

Posted: 17 Days ago by: Julio Di Egidio

You tell, but it's quite obvious that you (just) run a regex on a string and captures are going to be strings: indeed, '02' is not a number either... Julio

Re: Instatiating module / Reusing module of command-line tool (thread)

comp.lang.python

Posted: 17 Days 8 Hours ago by: Stefan Ram

A module is an /object/ (instance) of the class "module". In software engineering, the singleton pattern is a software design pattern that restricts the instantiation of a class to one /single/ instance. The class "module" is not

Re: Instatiating module / Reusing module of command-line tool (thread)

comp.lang.python

Posted: 17 Days 15 Hours ago by: Stefan Ram

If you need a class, you can write a class. When one imports a module, the module actually gets executed. That's why people write "if __name__ == '__main__':" often. So, everything one wants to be done at import time can be wr

Re: Match.groupdict: Meaning of default argument? (thread)

comp.lang.python

Posted: 17 Days 15 Hours ago by: Stefan Ram

It will get the value '0' if (?P<days>\d*) does /not/ participate in the match. In your case, it /does/ participate in the match, \d* matching the empty string. Try (?P<days>\d+)?.

Instatiating module / Reusing module of command-line tool

comp.lang.python

Posted: 17 Days 17 Hours ago by: Loris Bennett

Hi, I have a command-line script in Python to get the correct salutation for a user name in either English or German from a 'salutation server': $ get_salutation alice Dear Professor Müller $ get_salutation alice -l de Sehr geeh

Testing an app protected by Okta authorization code with PKCE flow

comp.lang.python

Posted: 17 Days 21 Hours ago by: George Fischhof

Hi Folks, has anyone of you a working solution for testing an app protected by Okta authorization code with PKCE flow? Meaning to get a bearer token? I saw / read several articles about it on the net, and several hacks (that is not proble

Match.groupdict: Meaning of default argument?

comp.lang.python

Posted: 17 Days 22 Hours ago by: Loris Bennett

Hi, If I do import re pattern = re.compile(r'(?P<days>\d*)(-?)(?P<hours>\d\d):(?P<minutes>\d\d):(?P<seconds>\d\d)') s = '104-02:47:06' match = pattern.search(s) match_dict = match.groupdict('0') I get match_dict {'days':

Re: Printing Unicode strings in a list

comp.lang.python

Posted: 18 Days 10 Hours ago by: Rob Cliffe

Still, if you're feeling noble, you could start the work of making your code Python 3 compatible.馃榿 Best wishes Rob Cliffe

Async SIG post

comp.lang.python

Posted: 18 Days 16 Hours ago by: Ethan Furman

Anybody interested in asynchronous programming may want to check out async-sig@python.org as it has an interesting post about ASGI and PEPs 3156 and 3333. Sign up at https://mail.python.org/mailman3/lists/async-sig.python.org/

Re: Printing Unicode strings in a list

comp.lang.python

Posted: 18 Days 17 Hours ago by: Stephen Tucker

To Cameron Simpson, Thanks for your in-depth and helpful reply. I have noted it and will be giving it close attention when I can. The main reason why I am still using Python 2.x is that my colleagues are still using a GIS system that has

Re: Printing Unicode strings in a list

comp.lang.python

Posted: 18 Days 18 Hours ago by: Cameron Simpson

Love to hear those reasons. Not suggesting that they are invalid. Because print() prints the str() or each of its arguments, and str() of a list if the same as its repr(), which is a list of the repr()s of every item in the list. Repr

Re: Printing Unicode strings in a list

comp.lang.python

Posted: 18 Days 18 Hours ago by: Jon Ribbens

print(x) implicitly calls str(x) to convert 'x' to a string for output. lists don't have their own str converter, so fall back to repr instead, which outputs '[', followed by the repr of each list item separated by ', ', followed by ']'.

Printing Unicode strings in a list

comp.lang.python

Posted: 18 Days 19 Hours ago by: Stephen Tucker

Hi PythonList Members, Consider the following log from a run of IDLE: ================== Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information

Re: logging library python (thread)

comp.lang.python

Posted: 19 Days 5 Hours ago by: Dan Stromberg

You probably want getLogger(__name__)

Re: Converting hex data to image

comp.lang.python

Posted: 19 Days 6 Hours ago by: anas el amouri

bonjour a tous ,la vidéo résout ce problème https://www.youtube.com/watch?v=GkxsYFQj0QM&ab_channel=TheRocketProgrammer

Re: windows 11 what is wrong?

comp.lang.python

Posted: 19 Days 7 Hours ago by: Dennis Lee Bieber

This forum only accepts text. Do not attach screen grabs of windows, just highlight the console TEXT and cut/paste same. The most likely guess would be that these items are not defined in your PATH environment variable.

logging library python

comp.lang.python

Posted: 19 Days 11 Hours ago by: tamar wase

hello, we have many scripts of one project. what is the right way to define the logger to all scripts? we tried to create class that define the logger configuration+generic function (handler functions to write generic log message), and e

Re: windows 11 what is wrong?

comp.lang.python

Posted: 19 Days 11 Hours ago by: Lars Martin Hambro

Repair passed but pip3 and pip did not find pip.exe and missing modules. Lars Martin hambro ________________________________ Fra: Lars Martin Hambro <lars_martin4@hotmail.com> Sendt: onsdag 27. april 2022, 21:31 Til: python-list@python.or

logging library python

comp.lang.python

Posted: 19 Days 11 Hours ago by: 转诪专 讜讜住讛

hello, we have many scripts of one project. what is the right way to define the logger to all scripts? we tried to create class that define the logger configuration+generic function (handler functions to write generic log message), and e

Re: ANN: Dogelog Player 0.9.8 (thread)

comp.lang.python

Posted: 19 Days 19 Hours ago by: Mostowski Collapse

Can your Prolog system run this example indefinitely? ?- A=(1=1,call(A)), A. But there is much more than what meets the eye. Dogelog Player is a 100% Prolog written Prolog interpreter that runs on the Python and JavaScript platform. It

Please can i have your attention

comp.lang.python

Posted: 19 Days 20 Hours ago by: Julian Bikarm

Dear , Please can I have your attention and possibly help me for humanity's sake please. I am writing this message with a heavy heart filled with sorrows and sadness. Please if you can respond, i have an issue that i will be most gratefu

Sorting (text testing software)

comp.lang.python

Posted: 19 Days 22 Hours ago by: moi

.... 'jésus', 'ayant cause', 'Côté', 'vice-légat', 'pêche', 'sot-l’y-laisse', .... 'coté', 'sûrement', 'vice-consul', 'lanthane', 'Jésus', 'maçon', .... 'à\xa0vau\xa0l’eau', 'péchère', 'suréminent', 'hema-', 'ay

Re: ANN: eGenix Antispam Bot for Telegram 0.3.0

comp.lang.python

Posted: 19 Days 22 Hours ago by: moi

I guess we should read - Marc-André Lemburg - Düsseldorf - Pastor-Löh-Str / Pastor-Löh-Straße

Re: matplotlib: scatterplot and histogram with same colour scale (thread)

comp.lang.python

Posted: 20 Days 22 Hours ago by: Loris Bennett

Now I have written down the problem with MWE I can see that the mapping of the colours to the patches of the histogram is wrong. The following values illustrate the problem much better efficiencies = [51, 52, 53, 54, 55, 56, 57, 58,

matplotlib: scatterplot and histogram with same colour scale

comp.lang.python

Posted: 20 Days 22 Hours ago by: Loris Bennett

Hi, I am using matplotlib to create scatterplot where the colour depends on the y-value. Additionally I want to project the y-values onto a rotated histogram along the right side of the scatterplot. My problem is that with my current c

Re: Style for docstring (thread)

comp.lang.python

Posted: 21 Days 4 Hours ago by: Stefan Ram

You know better than Rob himself what produces a mild cognitive dissonance for him? The phenomenon of cognitive dissonance does not have much to do with split personalities.

Re: Style for docstring

comp.lang.python

Posted: 21 Days 4 Hours ago by: dn

Disagree! When coding, to whom?what are you talking? When writing documentation - same question? This is the reason why (typically) coders are pretty bad at, or disagree with a need for, 'documentation' - and particularly documentation

Re: Style for docstring

comp.lang.python

Posted: 21 Days 6 Hours ago by: Rob Cliffe

Well, de gustibus non est disputandum.  For me, the switch from the imperative mode to the descriptive mode produces a mild cognitive dissonance. Best wishes Rob Cliffe On 25/04/2022 23:34, Cameron Simpson wrote:

Re: Style for docstring

comp.lang.python

Posted: 21 Days 7 Hours ago by: Mats Wichmann

Just as another data point, if nothing else to prove there will never be consensus :) - Google's style guide is pretty explicit about what they expect: Bigtable.""") rather than imperative-style ("""Fetch rows from a Bigtable.""").

Re: tail

comp.lang.python

Posted: 21 Days 7 Hours ago by: dn

I like it! Yes, in the context of memory-limited mainframes being in-the-past, and our thinking has, or needs to, moved-on; memory is so much 'cheaper' and thus available for use! That said, it depends on file-size and what else is goi

Re: tail

comp.lang.python

Posted: 21 Days 7 Hours ago by: Cameron Simpson

If you make the chunk big enough, they're the same algorithm! It sound silly, but if you make your chunk size as big as your threshold for "this file is too big to read serially in its entirety, you may as well just write the "last chu

Re: Style for docstring

comp.lang.python

Posted: 21 Days 8 Hours ago by: Cameron Simpson

I'm in the imperative camp. But if I think the function requires some elaboration, _then_ I provide description: def f(x): ''' Return the frobnangle of `x`. This iterates over the internals of `x` in blah order

Re: Verifying I installed Python correctly (thread)

comp.lang.python

Posted: 21 Days 8 Hours ago by: Stefan Ram

If you're comfortable with the command line: Create the file "hello.py" with the line "print( 'hello!' )" and call "py" with the argument "hello.py" on the command line. If you're not comfortable with the command line: Learn

Re: Verifying I installed Python correctly

comp.lang.python

Posted: 21 Days 8 Hours ago by: Eryk Sun

Yes, except the app versions installed from the Microsoft Store do create appexec aliases for python.exe, python3.exe, and python3.x.exe (e.g. python3.10.exe). The aliases for installed versions can be toggled separately, so "python.exe"

Re: Verifying I installed Python correctly

comp.lang.python

Posted: 21 Days 9 Hours ago by: Dennis Lee Bieber

Microsoft Windows [Version 10.0.19044.1645] (c) Microsoft Corporation. All rights reserved. C:\Users\Wulfraed>python3 Python ActivePython 3.8.2 (ActiveState Software Inc.) based on on win32 Type "help", "copyright", "credits" or "lice

Re: Verifying I installed Python correctly

comp.lang.python

Posted: 21 Days 9 Hours ago by: Barry

Will not work on windows. Python is always installed as python.exe and py.exe only. Barry

Re: Verifying I installed Python correctly

comp.lang.python

Posted: 21 Days 10 Hours ago by: Jack Dangler

Have you tried python3 hello.py

Re: Verifying I installed Python correctly

comp.lang.python

Posted: 21 Days 11 Hours ago by: Dennis Lee Bieber

Text only, no images on this forum. Cut&Paste the TEXT from your console window, not a screen grab. And... with that... show us the exact text. The text you show above IS invalid -- paths do not end with > character (that, when show

Re: Verifying I installed Python correctly

comp.lang.python

Posted: 21 Days 11 Hours ago by: Sunil KR

cd C:\google-python-exercises> python hello.py this doesn't looks like a valid command. However, is it because a newline got swallowed by misformatting? For clarity, I am reproducing the correct version of the steps: cd /d  C:\google

Re: Verifying I installed Python correctly

comp.lang.python

Posted: 21 Days 12 Hours ago by: Barry

Use can use py instead of python as a command and it should work. py hello.py Barry

Solutions Manual Test Bank for Marketing Management 4th Edition By

comp.lang.python

Posted: 21 Days 13 Hours ago by: Yifang Xie

Marketing Management 4th Edition By Greg Marshall and Mark Johnston ISBN10: 1260381919 ISBN13: 9781260381917 TO REQUEST SMTB, E-mail Us at pro.fast @ hotmail dot com We also provide help in CONNECT Homeworks, CONNECT Assignments, LearnSma

Test Bank, Solutions for Marketing 16th Edition By Roger Kerin

comp.lang.python

Posted: 21 Days 13 Hours ago by: Yifang Xie

Marketing 16th Edition By Roger Kerin and Steven Hartley ISBN10: 1264121326 ISBN13: 9781264121328 TO REQUEST SMTB, E-mail Us at pro.fast @ hotmail dot com We also provide help in CONNECT Homeworks, CONNECT Assignments, LearnSmart Quizzes.

Solutions and Test Bank For Customer Service Skills for Success 8th

comp.lang.python

Posted: 21 Days 13 Hours ago by: Yifang Xie

Customer Service Skills for Success 8th Edition By Robert Lucas ISBN10: 1260381900 ISBN13: 9781260381900 TO REQUEST SMTB, E-mail Us at pro.fast @ hotmail dot com We also provide help in CONNECT Homeworks, CONNECT Assignments, LearnSmart

Test Bank and Solutions For Essentials of Economics 12th Edition By

comp.lang.python

Posted: 21 Days 13 Hours ago by: Yifang Xie

Essentials of Economics 12th Edition By Bradley Schiller and Karen Gebhardt ISBN10: 1264122101 ISBN13: 9781264122103 TO REQUEST SMTB, E-mail Us at pro.fast @ hotmail dot com We also provide help in CONNECT Homeworks, CONNECT Assignments,

Re: Receive a signal when waking or suspending?

comp.lang.python

Posted: 21 Days 14 Hours ago by: Skip Montanaro

Yeah, that won't help. uptime(1) gives the time since the last boot. Wake/suspend doesn't change the system's notion of boot time. https://www.geeksforgeeks.org/python-script-to-shows-laptop-battery-percentage/ I actually already have p

Re: Why no list as dict key?

comp.lang.python

Posted: 21 Days 16 Hours ago by: Lars Liedtke

Thx, didn't see it that way yet.

Re: Why no list as dict key?

comp.lang.python

Posted: 21 Days 16 Hours ago by: Peter J. Holzer

--s5mvekgsi5rz5qfl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2022-04-25 15:13:19 +0200, Lars Liedtke wrote: A string is also an immutable iterable, so this is p

Re: Why no list as dict key?

comp.lang.python

Posted: 21 Days 17 Hours ago by: Lars Liedtke

May I stupidly ask, why one would want to use an iterable (even immutable) as dict key? I thought keys were meant to be something "singular". And yes you could also combine a string to be a key, and if you combine a string it would be s

ANN: eGenix Antispam Bot for Telegram 0.3.0

comp.lang.python

Posted: 21 Days 20 Hours ago by: eGenix Team

________________________________________________________________________ ANNOUNCING eGenix Antispam Bot for Telegram Version 0.3.0 A simple, yet effective bot implementation

Re: Style for docstring (thread)

comp.lang.python

Posted: 22 Days 10 Hours ago by: Avi Gross

Yes, Michael, a dictionary is an excellent way to represent a closed set of transitions which your permutations are. You examples use numerals but obviously a dictionary will allow transformations of anything that can be hashed which mos

Re: tail

comp.lang.python

Posted: 22 Days 10 Hours ago by: dn

Thanks for the clarification (and @wlfraed's addition). Apologies if misunderstood. The above comment was about utilities which would choose between algorithms, based on some rapid, initial, assessment of the task. It was not about 'tai

Re: Style for docstring (thread)

comp.lang.python

Posted: 22 Days 10 Hours ago by: dn

Yes, we live and learn! (but 'technical debt'...) Naming something based upon its implementation, eg ValidateDict(), rather than its purpose, is a definite no-no - and while I'm nit-picking, is that a function? (and thus validate_dict()

Verifying I installed Python correctly

comp.lang.python

Posted: 22 Days 12 Hours ago by: Greg

I am trying to get Hello World to appear under my directory. The files of *C:\Users\gd752>cd C:\google-python-exercises> python hello.py* *The system cannot find the path specified.* *C:\Users\gd752>cd C:\google-python-exercises>* *The sy

Re: tail

comp.lang.python

Posted: 22 Days 13 Hours ago by: Dennis Lee Bieber

IBM wasn't the only one... Xerox Sigma running CP/V default for text files (those created using a text editor) used numeric ISAM keys (as record numbers -- which is how their FORTRAN IV compiler did random access I/O without requiring f

RE: tail

comp.lang.python

Posted: 22 Days 14 Hours ago by: <pjfarley3

<Snipped> WRT the mentioned IBM utility program[me]s, the non-Posix part of the IBM mainframe file system has always provided record-managed storage since the late 1960's (as opposed to the byte-managed storage of *ix systems) so searchin

Re: tail

comp.lang.python

Posted: 22 Days 14 Hours ago by: Marco Sulla

Well, the inverse reader is only a secondary suggestion. I suppose a tail is much more useful.

Re: tail

comp.lang.python

Posted: 22 Days 14 Hours ago by: Chris Angelico

Not always. If you know you want to read 5 lines, it's much more efficient than reading 1 line, then going back to the file, five times. Disk reads are the costliest part, with the possible exception of memory usage (but usually only beca

Re: tail

comp.lang.python

Posted: 22 Days 14 Hours ago by: Marco Sulla

Ah, I played very little with mmap, I didn't know about this. So I suppose you can locate the newline and at that point read the line without using chunks?

Re: tail

comp.lang.python

Posted: 22 Days 14 Hours ago by: Marco Sulla

Well, I would like to have a sort of tail, so to generalise to more than 1 line. But I think that once you have a good algorithm for one line, you can repeat it N times. I understand that you can read a chunk instead of a single byte, s

Re: How to have python 2 and 3 both on windows?

comp.lang.python

Posted: 22 Days 16 Hours ago by: Eryk Sun

`#!py -3` is not a valid shebang for the py launcher. Use `#!python3` to run a script with the highest version of Python 3 that's registered on your system. Or for cross-platform support, use `#!/usr/bin/python3`. The launcher supports

Re: Style for docstring (thread)

comp.lang.python

Posted: 22 Days 16 Hours ago by: Michael F. Stemper

The below was *not* intended to illustrate what I said above. It shows the validation function provided by the module. This allows the user to avoid the consequences of an invalidly-constructed permutation. (It's only for users who don't

Re: Style for docstring (thread)

comp.lang.python

Posted: 22 Days 17 Hours ago by: Michael F. Stemper

Since you ask, I'm using dictionaries as the internal representation. If you think about it, a python dictionary *is* a function from one finite set to another, mathematically. And a (finite) permutation is a bijection from a (finite) set

Re: tail

comp.lang.python

Posted: 22 Days 18 Hours ago by: Avi Gross

I have been getting confused by how many interpretations and conditions for chasing tail people seem to be talking about. A fairly normal task is to want to see just the last N lines of a text-based file.  A variant is the "tail -f" com

Re: tail

comp.lang.python

Posted: 22 Days 19 Hours ago by: Chris Angelico

You still need to read the entire file, and you also restrict the max line count, so you can't iterate this to take the next block of lines. ChrisA

Re: tail

comp.lang.python

Posted: 22 Days 19 Hours ago by: Antoon Pardon

Why not just do: tail = collections.deque(text_stream, maxlen = nr_of_lines) tail.reverse() ....

Re: tail

comp.lang.python

Posted: 22 Days 21 Hours ago by: Roel Schroeven

If I understand Marco correctly, what he want is to read the lines from bottom to top, i.e. tac instead of tail, despite his subject. I use tail very frequently too, but tac is something I almost never use.

Re: How to have python 2 and 3 both on windows?

comp.lang.python

Posted: 22 Days 22 Hours ago by: Peter J. Holzer

--knvpl3hbcgo4p2hi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2022-04-24 01:19:38 +0000, Sunil KR via Python-list wrote: You haven't shown us how you invoke thos

Re: How to have python 2 and 3 both on windows?

comp.lang.python

Posted: 22 Days 23 Hours ago by: Sunil KR

When I have both python 2 and python3, why is my python 2 script breaking? And when I remove python3 the problem goes away? In both cases (regardless of installing python 3 or not) I am using only python 2 to run the python2 script. Why

Re: How to have python 2 and 3 both on windows?

comp.lang.python

Posted: 23 Days 3 Hours ago by: Dennis Lee Bieber

In python2, the default for strings is BYTES -- you must explicitly ask for unicode (for literals, using u'literal' notation). Python3 strings are, by default, interpreted as unicode (with the encoding for source code [and hence, litera

Re: How to have python 2 and 3 both on windows?

comp.lang.python

Posted: 23 Days 5 Hours ago by: Sunil KR

I am happy with how the python starts up. When I use python I get python 2.  I am ok with using py -3 for my new scripts, even using the shebang like #!py -3 I don't want to put a unix (or for that matter windows) path in the shebang, as i

Re: tail

comp.lang.python

Posted: 23 Days 6 Hours ago by: Chris Angelico

Yeah, I think pretty much *anything* would be better than single byte seeks. ChrisA

Re: tail

comp.lang.python

Posted: 23 Days 6 Hours ago by: Cameron Simpson

True. I'd expect better than single byte seek/read though. Fair. But it would be much easier to read code. Cheers, Cameron Simpson <cs@cskk.id.au>

Re: Style for docstring (thread)

comp.lang.python

Posted: 23 Days 7 Hours ago by: dn

I've always taken the PEP somewhat for granted (with belated thanks and respect to the authors and others who exerted effort (or would that be, efforts?) to publish the finished work. One of the things that I've taken-as-read, is WHY we

Re: tail

comp.lang.python

Posted: 23 Days 8 Hours ago by: Chris Angelico

Yeah, I made a vague allusion to use of mmap, but didn't elaborate because I actually have zero idea of how efficient this would be. Would it be functionally equivalent to the chunking, but with the chunk size defined by the system as wha

Re: tail

comp.lang.python

Posted: 23 Days 8 Hours ago by: Chris Angelico

tail(1) doesn't read a single byte at a time. It works in chunks, more-or-less the way I described. (That's where I borrowed the technique from.) It finds one block of lines, and displays those; it doesn't iterate backwards. (By the way,

Re: tail

comp.lang.python

Posted: 23 Days 8 Hours ago by: Chris Angelico

Yeah. I said "easier", not necessarily more efficient. Which is more efficient is a virtually unanswerable question (will you need to iterate over the whole file or stop part way? Is the file stored contiguously? Can you memory map it in

Re: tail

comp.lang.python

Posted: 23 Days 8 Hours ago by: Cameron Simpson

[...] For some encodings that generalisation might be hard. But mostly, yes. An approach I think you both may have missed: mmap the file and use mmap.rfind(b'\n') to locate line delimiters. https://docs.python.org/3/library/mmap.html#m

Re: tail

comp.lang.python

Posted: 23 Days 8 Hours ago by: dn

.... Disagreeing with @Chris in the sense that I use tail very frequently, and usually in the context of server logs - but I'm talking about the Linux implementation, not Python code! Agree with @Chris' assessment of the (in)efficiency

Re: tail

comp.lang.python

Posted: 23 Days 8 Hours ago by: Peter J. Holzer

--ayqtziuqigxperpn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2022-04-24 04:57:20 +1000, Chris Angelico wrote: [...] Which one is more efficient depends very muc

Re: Receive a signal when waking or suspending?

comp.lang.python

Posted: 23 Days 8 Hours ago by: Skip Montanaro

Thanks, that gives me something to munch on.

Re: Receive a signal when waking or suspending?

comp.lang.python

Posted: 23 Days 9 Hours ago by: dn

Re: tail

comp.lang.python

Posted: 23 Days 9 Hours ago by: Chris Angelico

Ah. Well, then, THAT is why it's inefficient: you're seeking back one single byte at a time, then reading forwards. That is NOT going to play nicely with file systems or buffers. Compare reading line by line over the file with readlines(

Re: tail

comp.lang.python

Posted: 23 Days 9 Hours ago by: Marco Sulla

Emh, why chunks? My function simply reads byte per byte and compares it to b"\n". When it find it, it stops and do a readline(): def tail(filepath): """ @author Marco Sulla @date May 31, 2016 """ try: filepat

Re: tail

comp.lang.python

Posted: 23 Days 9 Hours ago by: Chris Angelico

It depends on which is more costly: reading the whole file (cost depends on size of file) or reading chunks and splitting into lines (cost depends on how well you guess at chunk size). If the lines are all *precisely* the same number of b

Re: tail

comp.lang.python

Posted: 23 Days 10 Hours ago by: Marco Sulla

Well, indeed I have an implementation that does more or less what you described for utf8 only. The only difference is that I just started from the end of file -1. I'm just wondering if this will be useful in the stdlib. I think it's not t

Re: Receive a signal when waking or suspending?

comp.lang.python

Posted: 23 Days 10 Hours ago by: Marco Sulla

I don't know in Python, but maybe you can create a script that writes on a named pipe and read it from Python? https://askubuntu.com/questions/226278/run-script-on-wakeup

Receive a signal when waking or suspending?

comp.lang.python

Posted: 23 Days 11 Hours ago by: Skip Montanaro

It's not clear there is a straightforward way to catch a signal or get an event notification when my computer (Dell running XUbuntu 20.04) is about to sleep or when it's just awakened. The app uses tkinter. Is there some more-or-less easy w

Re: Style for docstring (thread)

comp.lang.python

Posted: 23 Days 11 Hours ago by: jan

"return true iff this". I like this. jan On 23/04/2022, Stefan Ram <ram@zedat.fu-berlin.de> wrote:

Re: tail

comp.lang.python

Posted: 23 Days 11 Hours ago by: Chris Angelico

It's fundamentally difficult to get precise. In general, there are three steps to reading the last N lines of a file: 1) Find out the size of the file (currently, if it's being grown) 2) Seek to the end of the file, minus some threshold

Re: Style for docstring (thread)

comp.lang.python

Posted: 23 Days 12 Hours ago by: Dan Stromberg

Maybe try pydocstyle?

tail

comp.lang.python

Posted: 23 Days 12 Hours ago by: Marco Sulla

What about introducing a method for text streams that reads the lines from the bottom? Java has also a ReversedLinesFileReader with Apache Commons IO.

Re: Style for docstring (thread)

comp.lang.python

Posted: 23 Days 13 Hours ago by: Avi Gross

Given what you added, Michael, your function is part of a larger collection of functions and being compatible with the others is a valid consideration. Whatever you decide, would ideally be done consistently with all or most of them. An

Re: Style for docstring (thread)

comp.lang.python

Posted: 23 Days 15 Hours ago by: Michael F. Stemper

I'll take a look at the PEP. Thanks.

Re: upgrade pip

comp.lang.python

Posted: 23 Days 17 Hours ago by: Eryk Sun

You have pip installed for the current user, but Python is installed for all users. I'd delete the package directory "%AppData%\Python\Python310\site-packages\pip". Then run ensurepip and upgrade from an administrator shell. This will ins

Re: Style for docstring (thread)

comp.lang.python

Posted: 23 Days 17 Hours ago by: Michael F. Stemper

That's a fair point. However, this function will be the 22nd one in a module for dealing with permutations and groups of permutations. The module has a lengthy docstring explaining the several ways provided to specify a permutation. That

Re: Style for docstring (thread)

comp.lang.python

Posted: 23 Days 20 Hours ago by: Stefan Ram

The commands, er, names of functions, use the imperative mood ("print", not "prints"). So, "return" aligns with that mood as a paraphrase of such names. In Java, at one point, they decided to start to use the third person at o

Re: Style for docstring (thread)

comp.lang.python

Posted: 24 Days 2 Hours ago by: Julio Di Egidio

If you work for a company that sucks at it, as more and more do (compared to today, if you think in the 80's we had a software crisis, you have no clue), you do NOT abide to it: that's not the mission unless you ask HR or your local coun

Re: Style for docstring (thread)

comp.lang.python

Posted: 24 Days 3 Hours ago by: Julio Di Egidio

You just need to learn some professional programming. "Return*s* true if the permutation is even, otherwise false" or better: "Returns whether the permutation is even" or even better: "Returns whether the given permutation is even" No

Re: Style for docstring (thread)

comp.lang.python

Posted: 24 Days 3 Hours ago by: Avi Gross

We know some people using "professional" language make things shorteror talk from a point of view different than others and often in otherwise incomprehensible jargon. If a programmer is taking about the algorithm that a function impleme

Re: Style for docstring (thread)

comp.lang.python

Posted: 24 Days 3 Hours ago by: Avi Gross

Python does have a concept of "truthy" that includes meaning for not just the standard Booleans but for 0 and non-zero and the empty string and many more odd things such as an object that defines __bool__ (). But saying it returns a Bool

Re: Style for docstring (thread)

comp.lang.python

Posted: 24 Days 5 Hours ago by: MRAB

Maybe it's because the function name is often also an imperative, e.g.: Help on function search in module re: search(pattern, string, flags=0) Scan through string looking for a match to the pattern, returning a Match object, o

Re: Style for docstring

comp.lang.python

Posted: 24 Days 6 Hours ago by: Cameron Simpson

Yeah, this. I've got lots of "test and return a Boolean" functions named "is_something" and some "test and raise value error if bad" functions named "validate_something". Those latter are so that I can concisely write stuff like:

Re: Style for docstring (thread)

comp.lang.python

Posted: 24 Days 6 Hours ago by: Chris Angelico

The point of docstrings is that they can be read by various tools. Otherwise, they are every bit as good as comments. That's a very broad convention; for instance, git commit messages are conventionally written imperatively, too. You ca

Re: Style for docstring (thread)

comp.lang.python

Posted: 24 Days 7 Hours ago by: Rob Cliffe

I don't use docstrings much; instead I put a line or two of comments after the `def ` line. But my practice in such situations is as per the OP's 3rd suggestion, e.g.     # Returns True if ..... I'm curious as to why so many people pre

Re: Style for docstring (thread)

comp.lang.python

Posted: 24 Days 7 Hours ago by: 2QdxY4RzWzUUiLuE

Maybe, depending on the context and purpose of the application. I think we're agreeing, but the OP didn't provide that information. I've seen enough oddball (yes, that's my professional opinion :-)) APIs (and worked with enough program

Re: Style for docstring (thread)

comp.lang.python

Posted: 24 Days 8 Hours ago by: Chris Angelico

While it's definitely possible to have other results and other ways to deliver them, the return of a boolean would be the most obvious default. I'm assuming that the function is called something like "is_even()" and that it either is a

upgrade pip

comp.lang.python

Posted: 24 Days 8 Hours ago by: Tola Oj

im trying to upgrade my pip so i can install openpyxl. i though i had successfully upgraded pip, and then I was trying to install openpyxl, but I was getting this: C:\Users\ojomo>"C:\Program Files\Python310\python.exe" -m pip install --up

Re: Style for docstring (thread)

comp.lang.python

Posted: 24 Days 8 Hours ago by: 2QdxY4RzWzUUiLuE

"Test whether a permutation is even," while technically factual, leaves the reader to wonder what form the result takes, and what happens to that result. Yes, we'd all like to think that programmers are smart enough to *assume* that the

Re: How to have python 2 and 3 both on windows?

comp.lang.python

Posted: 24 Days 8 Hours ago by: Barry

I do not when it was first added all the installs I have done in the last few years have it working. Barry

Re: Style for docstring (thread)

comp.lang.python

Posted: 24 Days 9 Hours ago by: alister

four guidance I would sugest Pep257 as a start point which would suggest "Return True if permutation is even"

Re: Style for docstring (thread)

comp.lang.python

Posted: 24 Days 10 Hours ago by: Michael F. Stemper

"So let it be written. So let it be done." Two for two. Thanks.

Re: Style for docstring (thread)

comp.lang.python

Posted: 24 Days 10 Hours ago by: Ethan Furman

Third option. -- ~Ethan~

Re: Style for docstring (thread)

comp.lang.python

Posted: 24 Days 10 Hours ago by: Chris Angelico

I'd go with the third one, but "Return" rather than "Returns". Or possibly "Test whether a permutation is even". That's just one opinion though, others may disagree :) ChrisA

Style for docstring

comp.lang.python

Posted: 24 Days 11 Hours ago by: Michael F. Stemper

I'm writing a function that is nearly self-documenting by its name, but still want to give it a docstring. Which of these would be best from a stylistic point of view: Tells caller whether or not a permutation is even. Determines

Re: How to have python 2 and 3 both on windows?

comp.lang.python

Posted: 24 Days 12 Hours ago by: Mats Wichmann

Looks like this got added around 3.7... https://bugs.python.org/issue30362

Re: How to have python 2 and 3 both on windows?

comp.lang.python

Posted: 24 Days 13 Hours ago by: Gisle Vanem

Not here; 'py.exe -0' gives: Requested Python version (0) not installed Which PyInstaller version support this '-0' option?

Re: How to have python 2 and 3 both on windows?

comp.lang.python

Posted: 24 Days 13 Hours ago by: Sunil KR

- Upon running one of my python 2 scripts (using python2), I see this error:     """       ^SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 237-238: truncated \uXXXX escape I tried for a bit, but I c

Re: How to have python 2 and 3 both on windows?

comp.lang.python

Posted: 24 Days 13 Hours ago by: Barry

As you have proved you can install many versions of python at the same time on windows. In your scripts set the shebang to run the python version you want. E.g #!/usr/bin/python2 Or #!/usr/bin/python3 The python launcher py.exe will th

Re: struggle to upgrade pip on visual studio code

comp.lang.python

Posted: 24 Days 19 Hours ago by: Richard Damon

When a program name/path includes spaces, you need to put the whole name in quotes, like "C:\Program Files\Python310\python.exe" -m pip install --upgrade Now, if python is on your path (and 3.10 is the first python found), you should

struggle to upgrade pip on visual studio code

comp.lang.python

Posted: 24 Days 20 Hours ago by: Tola Oj

WARNING: You are using pip version 22.0.2; however, version 22.0.4 is available.You should consider upgrading via the 'C:\Program Files\Python310\python.exe -m pip install --upgrade pip' command. And then when I try to upgrade using 'C:\

How to have python 2 and 3 both on windows?

comp.lang.python

Posted: 25 Days 1 Hour ago by: Sunil KR

I have some scripts that are old and won't work under python2 and at the same time I am writing new scripts which will use python3. However, if python 2 and 3 cannot co-exist in a windows box it will be impossible to transition What I try:-

Re: Having trouble getting Hello World to appear

comp.lang.python

Posted: 25 Days 4 Hours ago by: MRAB

"auto version"? I don't know, because you didn't say what did or didn't happen. Did it say it couldn't find Python? If yes, try the Python Launcher instead: py hello.py

Re: Enums and nested classes

comp.lang.python

Posted: 25 Days 4 Hours ago by: Ethan Furman

Indeed -- the point of the question is to (hopefully) find out what folks have already tried, and whether they found the current behavior surprising. We're looking for what happened in practice, not for what should happen in theory. ;-

Re: Having trouble getting Hello World to appear

comp.lang.python

Posted: 25 Days 4 Hours ago by: Greg

I downloaded and installed the auto version of the software. I go to the director C:\google-python-exercises> *python hello.py* I am running Windows. What am I doing incorrectly? I had the zip file installed under my One Drive and t

Re: Enums and nested classes

comp.lang.python

Posted: 25 Days 8 Hours ago by: Greg Ewing

That's a pretty open-ended question. Is there something about its current behaviour that you think should be different?

Re: code issue

comp.lang.python

Posted: 25 Days 8 Hours ago by: Greg Ewing

Also, the output you showed contains blank lines and lines with hyphens, and there is nothing in the code you posted which does that. If I had to guess, I'd say you have a loop which is supposed to repeatedly read a value for n and then

Re: code issue

comp.lang.python

Posted: 25 Days 12 Hours ago by: Chris Angelico

Fizz Buzz is a very common assignment. The point isn't to get a correct version, the point is to understand what it's doing :) ChrisA

Re: code issue

comp.lang.python

Posted: 25 Days 12 Hours ago by: Jack Dangler

fizzbuzz is one of Angela Yu's lab assignments in her py course.If you ask her, she'll gladly tell you where you are going wrong and even supply an entirely correct version, if you want it...

Re: code issue

comp.lang.python

Posted: 25 Days 13 Hours ago by: Chris Angelico

This can't be your complete code, because it won't run like this. Have a very careful read through of your code, and consider adding some extra print statements to see what's happening; but if you're asking for help, you'll definitely nee

code issue

comp.lang.python

Posted: 25 Days 13 Hours ago by: Tola Oj

.. if i is a multiple of both 3 but not 5, print fizz. ..if i is a multiple of 5 but not 3, print buzz

Re: Tuple unpacking inside lambda expressions

comp.lang.python

Posted: 25 Days 16 Hours ago by: Peter Otten

Hm, I don't see pmap, but there is a starmap(): https://docs.python.org/3/library/multiprocessing.html#multiprocessing.pool.Pool.starmap

Re: Why no list as dict key?

comp.lang.python

Posted: 26 Days 1 Hour ago by: Abdur-Rahmaan Janhan

As clear as daylight, thanks! Kind Regards, Abdur-Rahmaan Janhangeer about <https://compileralchemy.github.io/> | blog <https://www.pythonkitchen.com> github <https://github.com/Abdur-RahmaanJ> Mauritius

Re: Why no list as dict key?

comp.lang.python

Posted: 26 Days 1 Hour ago by: Chris Angelico

The point of the hash is to find things that are equal. That's why 1234, 1234.0, and 0j+1234.0 all have the same hash. If equality changes, the hash does too. It's certainly possible to have the hash come from object identity, but then s

Re: Why no list as dict key?

comp.lang.python

Posted: 26 Days 3 Hours ago by: Dan Stromberg

If you need mutable keys, you /might/ create a dict-like-object using what functional languages call an association list. But these have O(n) lookups, not O(1) like a dict (AKA hash table). And even then, if you have keys a and b, a !=

Re: Why no list as dict key?

comp.lang.python

Posted: 26 Days 3 Hours ago by: Abdur-Rahmaan Janhan

Assumes checking for object equality before inserting. If they are they same, do we need different hashes? Kind Regards, Abdur-Rahmaan Janhangeer about <https://compileralchemy.github.io/> | blog <https://www.pythonkitchen.com> github <h

Re: Why no list as dict key?

comp.lang.python

Posted: 26 Days 3 Hours ago by: 2QdxY4RzWzUUiLuE

Then you have a different problem. x = [1, 2, 3] y = [n for n in 1, 2, 3] Those two lists (x and y) are separate but equal objects. Being separate, pointers to them would not be equal. Being equal, they have to have the same

Re: Why no list as dict key?

comp.lang.python

Posted: 26 Days 4 Hours ago by: Abdur-Rahmaan Janhan

Thanks everybody, In the the event spam is appended a value, then looking for [1,2] does not return anything but looking for [1,2,3] yes. But i gather the way dictionaries are implemented makes it difficult to do so ... Maybe hashes shou

Re: Why no list as dict key?

comp.lang.python

Posted: 26 Days 4 Hours ago by: Greg Ewing

It sounds like you would be better off making all your equation data structures immutable. Instead of mutating the equation when making a transformation, return a new equation. Then you can use sets and dicts to cache them etc. without an

Re: Why no list as dict key?

comp.lang.python

Posted: 26 Days 7 Hours ago by: Greg Ewing

If the contents of the list were to change after using it as a key, its hash value would no longer match its position in the dict, so subsequent lookups could fail to find it.

Re: ANN: Dogelog Player 0.9.8 (thread)

comp.lang.python

Posted: 26 Days 9 Hours ago by: Mostowski Collapse

?- X = f(abc). X = f(abc). ?- X = f(abc), change_arg(1, X, def). X = f(def) I blogged recently about it on medium here. It can speed-up your Prolog system tremendously. I measure in Scryer Prolog: ?- time((between(1,1000,_), call_nth(c

Re: Why no list as dict key?

comp.lang.python

Posted: 26 Days 10 Hours ago by: Chris Angelico

Yes. And those situations are *exactly* why you can't use a list as a key. And if you don't mutate your data, use a tuple. ChrisA

Re: Why no list as dict key?

comp.lang.python

Posted: 26 Days 10 Hours ago by: Avi Gross

This does raise an issue, Chris, if you use the method of making a tuple companion for a list at a specific time just for use as a dictionary key, then later change the list, you can end up with various situations. Obviously the changed

Re: Why no list as dict key?

comp.lang.python

Posted: 26 Days 10 Hours ago by: Chris Angelico

Quickie: I'd be inclined to define hash on top of a tuple's hash, rather than try to design my own and hope that it's suitable. "return hash(tuple(self))" is a good demonstration of the parallel. Otherwise, good demonstration of the prob

Re: Why no list as dict key?

comp.lang.python

Posted: 26 Days 11 Hours ago by: Sam Ezeh

Repeating the above points, here is an example of what would happen if you tried. Dictionaries require their keys to be immutable as under-the-hood they use hash tables and they'd fail when the underlying values are allowed to change. ```

Re: Why no list as dict key?

comp.lang.python

Posted: 26 Days 12 Hours ago by: Chris Angelico

Greetings tuple, Because a list can be changed, which would change what it's equal to: False True If you use spam as a dict key, then mutate it in any way, it would break dict invariants of all kinds (eg you could also have used ham a

Re: Why no list as dict key?

comp.lang.python

Posted: 26 Days 12 Hours ago by: Larry Martell

Dict keys cannot be mutable. Use a tuple instead.

Re: Tuple unpacking inside lambda expressions

comp.lang.python

Posted: 26 Days 12 Hours ago by: Albert-Jan Roskam

I went back to the code recently and I remembered what the problem was. I was using multiprocessing.Pool.pmap which takes a callable (the lambda here) so I wasn't able to use comprehensions or starmap Is there anythi

Why no list as dict key?

comp.lang.python

Posted: 26 Days 12 Hours ago by: Abdur-Rahmaan Janhan

Greetings list, Using Python3.9, i cannot assign a list [1, 2] as key to a dictionary. Why is that so? Thanks in advanced! Kind Regards, Abdur-Rahmaan Janhangeer about <https://compileralchemy.github.io/> | blog <https://www.pythonkitche

RE: lambda issues

comp.lang.python

Posted: 26 Days 12 Hours ago by: Schachner, Joseph

Re: "...which takes a callable (the lambda here)" Python lamdas have some severe restrictions. In any place that takes a callable, if a lambda can't serve, just use def to write a function and use the function name. ---- Joseph S. Tel

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

comp.lang.python

Posted: 26 Days 13 Hours ago by: Mark Lawrence

Just in case nobody has mentioned it how about https://dateutil.readthedocs.io/en/stable/

Re: Tuple unpacking inside lambda expressions

comp.lang.python

Posted: 26 Days 19 Hours ago by: Sam Ezeh

I went back to the code recently and I remembered what the problem was. I was using multiprocessing.Pool.pmap which takes a callable (the lambda here) so I wasn't able to use comprehensions or starmap Is there anything for situations lik

Re: Tuple unpacking inside lambda expressions

comp.lang.python

Posted: 26 Days 19 Hours ago by: Sam Ezeh

This also works great! Kind Regards, Sam Ezeh On Tue, 19 Apr 2022 at 12:03, Antoon Pardon <antoon.pardon@vub.be> wrote:

Enums and nested classes

comp.lang.python

Posted: 26 Days 19 Hours ago by: Sam Ezeh

Hello everyone, Has anyone here used or attempted to use a nested class inside an enum? If so, how did you find it? (what did you expect to happen and did your expectations align with resulting behaviour etc.) Here are two examples desc

Re: Proposal: Syntax for attribute initialisation in __init__ methods

comp.lang.python

Posted: 26 Days 20 Hours ago by: Sam Ezeh

I'll see if I can find out how positional only and keyword only arguments are used in __init__ methods in the wild and I'll see if there have been any other discussions talking about what this approach could offer. On Sun, 17 Apr 2022 at

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

comp.lang.python

Posted: 27 Days ago by: Loris Bennett

That is interesting. However, I am not claiming that the definition of a year as 365 24-hour days is in any way correct, merely that it is a possible definition and one that is potentially handy if one wants to represent large numbers o

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

comp.lang.python

Posted: 27 Days ago by: Loris Bennett

I have now understood this. It is what I need. It just doesn't do the trivial format conversion I (apparently incorrectly) expected. However, I can implement the format conversion myself. [snip (35 lines)]

Re: Pre-Pre-PEP: The datetime.timedeltacal class

comp.lang.python

Posted: 27 Days 8 Hours ago by: Random832

I'm not sure there's a guarantee that t + n day + m second may not be equal to t + m second + n day, either. This is possibly also something that we can look at what existing implementations do, though I'm concerned that the choice of "fo

Re: Why does datetime.timedelta only have the attributes 'days' and

comp.lang.python

Posted: 27 Days 8 Hours ago by: Random832

A timedelta *is* a pure period. A timedelta of one day is 86400 seconds. The thing you *think* timedelta does [making a day act as 23 or 25 hours across daylight saving boundaries etc], that you *don't* want it to do, is something it *do

Re: Why does datetime.timedelta only have the attributes 'days' and (thread)

comp.lang.python

Posted: 27 Days 9 Hours ago by: Jon Ribbens

Indeed, which is why "leap=not year & 3" works for years in range(1901, 2100). Which I have found useful before when programming in an assembly language that has no division operation ;-)

Re: Why does datetime.timedelta only have the attributes 'days' and (thread)

comp.lang.python

Posted: 27 Days 9 Hours ago by: Barry

Leap century is skip unless it’s a leap quadra century. Barry

Re: Why does datetime.timedelta only have the attributes 'days' and

comp.lang.python

Posted: 27 Days 10 Hours ago by: MRAB

So, a /day/ is a solar day, as distinct from a sidereal day. What's the difference? Well, a "sidereal day" is how long it takes for the Earth to rotate on its axis, but as it's also orbiting the Sun in the same direction, midday won't

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

comp.lang.python

Posted: 27 Days 12 Hours ago by: Dennis Lee Bieber

The Explanatory Supplement to the Astronomical Almanac (table 15.3) defines the /day/ as 24hrs->1440mins->86400secs BUT defines the Julian /year/ as 365.25 days. It goes on to also give (for my copy -- length of year at 1990): Tropic

Re: Why does datetime.timedelta only have the attributes 'days' and

comp.lang.python

Posted: 27 Days 13 Hours ago by: Chris Angelico

Thing is, there's a huge difference between: 1) "Eleven days, twenty-two hours, forty-four minutes, and fifty-five seconds" 2) "The period between 2nd May 2009 at 6AM and 5th June 2010 at 9AM" 3) "The period between 20th Feb 2016 at 10PM

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

comp.lang.python

Posted: 27 Days 16 Hours ago by: Loris Bennett

I'm sure you're right. I just strikes me as a little odd that so much effort has gone into datetime to make things work (almost) properly for (almost) everyone, whereas timedelta has remained rather rudimentary, at least in terms of for

Re: Why does datetime.timedelta only have the attributes 'days' and

comp.lang.python

Posted: 27 Days 16 Hours ago by: Jon Ribbens

Well, that's my point. Everyone's all in their own slightly-different little niches. There isn't one straightforward standard that makes all or even most of them happy.

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

comp.lang.python

Posted: 27 Days 16 Hours ago by: Loris Bennett

Yes, I do mean just the trivial definitions from https://docs.python.org/3/library/datetime.html i.e. A millisecond is converted to 1000 microseconds. A minute is converted to 60 seconds. An hour is converted to 3600 se

Re: Why does datetime.timedelta only have the attributes 'days' and

comp.lang.python

Posted: 27 Days 17 Hours ago by: Jon Ribbens

If by 'days' it means '86,400 seconds' then that's very easily convertible to and from timedelta. Eh? The definitions for "year, week, day" are not in the slightest bit trivial (unless you define 'day' as '86,400 seconds', in which case

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

comp.lang.python

Posted: 27 Days 17 Hours ago by: Loris Bennett

days-hours:minutes:seconds But most languages support fairly arbitrary formatting of timedate-style objects. It doesn't seem unreasonable to me that such formatting might be available for simple periods. Maybe. It just seems to me

Re: Why does datetime.timedelta only have the attributes 'days' and

comp.lang.python

Posted: 27 Days 18 Hours ago by: Jon Ribbens

That's exactly what timedelta is. I don't recognise that format and can't work out what it means. It should be trivial to write functions to parse whatever format you wanted and convert between it and timedelta objects though. I would

Re: Why does datetime.timedelta only have the attributes 'days' and 'seconds'?

comp.lang.python

Posted: 27 Days 19 Hours ago by: Loris Bennett

I now realise that timedelta is not really what I need. I am interested solely in pure periods, i.e. numbers of seconds, that I can convert back and forth from a format such as 11-22::44:55 (These are the lengths of time a job has r

Re: Tuple unpacking inside lambda expressions

comp.lang.python

Posted: 27 Days 19 Hours ago by: Antoon Pardon

Why not write: itertools.starmap(result.process, jobs)

Re: Suggestion for Linux Distro (from PSA: Linux vulnerability)

comp.lang.python

Posted: 28 Days 15 Hours ago by: Marco Sulla

Ah ok, now I understand. Sorry for the confusion.

Re: No shortcut Icon on Desktop

comp.lang.python

Posted: 28 Days 16 Hours ago by: Eryk Sun

Such people need to learn how to use the start menu, where all of Python's shortcuts are installed in a folder named "Python <X.Y>". One can also press the Windows key and type "python" to get a filtered view of the application shortcuts.

Re: Pre-Pre-PEP: The datetime.timedeltacal class

comp.lang.python

Posted: 28 Days 16 Hours ago by: Barry

Did you write the use cases? Without them how can anyone review the tests? Barry

Re: Pre-Pre-PEP: The datetime.timedeltacal class

comp.lang.python

Posted: 28 Days 18 Hours ago by: Peter J. Holzer

--mmsxfmanikbxty47 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2022-04-16 20:25:45 +0100, Barry wrote: Writing test cases is always a good idea :-) I have now wr

Re: Pre-Pre-PEP: The datetime.timedeltacal class

comp.lang.python

Posted: 29 Days 16 Hours ago by: Peter J. Holzer

--i6ssgimnpd74wqsw Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2022-04-17 10:15:54 +0200, Peter J. Holzer wrote: Thinking about it some more (while writing test

Re: Pre-Pre-PEP: The datetime.timedeltacal class

comp.lang.python

Posted: 29 Days 19 Hours ago by: Karsten Hilbert

It *still* means "take for 28 days" :-) Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B

Re: Pre-Pre-PEP: The datetime.timedeltacal class

comp.lang.python

Posted: 29 Days 20 Hours ago by: Chris Angelico

Ah, hmm. I'll have to play around with the Antarctica/Troll timezone a bit, but it could be that they track Oslo time when only Norwegians are there, and UTC when there are others? In any case, there are *plenty* of bizarre cases. Whethe

Re: is there somebody that have experince with python and canopen (thread)

comp.lang.python

Posted: 29 Days 21 Hours ago by: 鐜 瀹忓簻

More information plz. WH-2099 ________________________________ From: Python-list <python-list-bounces+wh2099=outlook.com@python.org> on behalf of luca72.b...@gmail.com <luca72.bertolotti@gmail.com> Sent: Saturday, April 16, 2022 1:18:33 AM

Re: Pre-Pre-PEP: The datetime.timedeltacal class

comp.lang.python

Posted: 29 Days 22 Hours ago by: Peter J. Holzer

--dowxcj3he7e73cif Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2022-04-17 06:08:54 +1000, Chris Angelico wrote: According to Wikipedia they switch between UTC+2 a

Re: Why does datetime.timedelta only have the attributes 'days' and

comp.lang.python

Posted: 29 Days 23 Hours ago by: Peter J. Holzer

--v6ja5zvqyl3g6iqm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2022-04-16 20:35:22 -0000, Jon Ribbens via Python-list wrote: What you *should* be able to do is us

397 recent articles found.

rocksolid light 0.7.2
clearneti2ptor