Re: Style for docstring

2022-04-25 Thread dn
On 26/04/2022 11.47, Rob Cliffe via Python-list wrote:
> Well, de gustibus non est disputandum.  For me, the switch from the
> imperative mode to the descriptive mode produces a mild cognitive
> dissonance.

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 that
doesn't fit inside a code-module!

(no insult, pure observation)

See earlier when I described taking a set of Requirements and
progressively applying specific clauses or requirements to a function.
One's thinking is in requirement-satisfaction-mode or 'design-mode'.
Later, when implementing the function, one can work in 'coding-mode'.

Separating tasks/roles removes the dissonance. No split-personality
required!

However, I know what you mean, and earlier today was writing to someone
about why I may not bother with a docstring if I'm in coding-mode and
wanting to 'keep going'. However, I see such as 'technical debt',
justified only in the hope that when I do get back to it (presumably
when the code is working, and I'm basking in the joys of (my own)
success, I'll be in more of a 'documentation' frame of mind...

(and pigs might fly!)



> On 25/04/2022 23:34, Cameron Simpson wrote:
>> On 23Apr2022 03:26, Avi Gross  wrote:
>>> 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
>>> implements, then, yes, they may write "scan" and "return".
>>> But if they realize the darn documentation is for PEOPLE asking
>>> how to use the darn thing, and want to write in more informal
>>> and understandable English, I think it makes more sense to say
>>> what the function does as in "scans" and importantly what it
>>> "returns" to the user as a result.
>> 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
>>  gathering the earliest items which are frobby and composes a
>>  nangle of the items.
>>  '''
>>
>> I very much like the concise imperative opening sentence, sometimes 2
>> sentences. Then the elaboration if the function isn't trivially obvious.
>>
>> Cheers,
>> Cameron Simpson 
> 

-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Style for docstring

2022-04-25 Thread Rob Cliffe via Python-list
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:

On 23Apr2022 03:26, Avi Gross  wrote:

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 implements, then, yes, they may write 
"scan" and "return".
But if they realize the darn documentation is for PEOPLE asking how to use the darn thing, and want 
to write in more informal and understandable English, I think it makes more sense to say what the 
function does as in "scans" and importantly what it "returns" to the user as a 
result.

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
 gathering the earliest items which are frobby and composes a
 nangle of the items.
 '''

I very much like the concise imperative opening sentence, sometimes 2
sentences. Then the elaboration if the function isn't trivially obvious.

Cheers,
Cameron Simpson 


--
https://mail.python.org/mailman/listinfo/python-list


Re: Style for docstring

2022-04-25 Thread Mats Wichmann
On 4/25/22 16:34, Cameron Simpson wrote:
> On 23Apr2022 03:26, Avi Gross  wrote:
>> 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 implements, 
>> then, yes, they may write "scan" and "return".
>> But if they realize the darn documentation is for PEOPLE asking how to use 
>> the darn thing, and want to write in more informal and understandable 
>> English, I think it makes more sense to say what the function does as in 
>> "scans" and importantly what it "returns" to the user as a result.
> 
> I'm in the imperative camp. But if I think the function requires some 
> elaboration, _then_ I provide description:

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:

> The docstring should be descriptive-style ("""Fetches rows from a
Bigtable.""") rather than imperative-style ("""Fetch rows from a
Bigtable.""").


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: tail

2022-04-25 Thread dn
On 26/04/2022 10.54, Cameron Simpson wrote:
> On 25Apr2022 08:08, DL Neil  wrote:
>> Thus, the observation that the OP may find that a serial,
>> read-the-entire-file approach is faster is some situations (relatively
>> short files). Conversely, with longer files, some sort of 'last chunk'
>> approach would be superior.
> 
> 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 chunk" flavour.


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 going-on in the
machine/total-application. (and that's 'probably not much' as far as
resource-mix is concerned!) However, I can't speak for the OP, the
reason behind the post, and/or his circumstances...
-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: tail

2022-04-25 Thread Cameron Simpson
On 25Apr2022 08:08, DL Neil  wrote:
>Thus, the observation that the OP may find that a serial,
>read-the-entire-file approach is faster is some situations (relatively
>short files). Conversely, with longer files, some sort of 'last chunk'
>approach would be superior.

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 chunk" flavour.

Cheers,
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Style for docstring

2022-04-25 Thread Cameron Simpson
On 23Apr2022 03:26, Avi Gross  wrote:
>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 implements, 
>then, yes, they may write "scan" and "return".
>But if they realize the darn documentation is for PEOPLE asking how to use the 
>darn thing, and want to write in more informal and understandable English, I 
>think it makes more sense to say what the function does as in "scans" and 
>importantly what it "returns" to the user as a result.

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  
gathering the earliest items which are frobby and composes a 
nangle of the items.
'''

I very much like the concise imperative opening sentence, sometimes 2 
sentences. Then the elaboration if the function isn't trivially obvious.

Cheers,
Cameron Simpson 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Verifying I installed Python correctly

2022-04-25 Thread Dennis Lee Bieber
On Mon, 25 Apr 2022 21:49:05 +0100, Barry 
declaimed the following:

>
>
>> On 25 Apr 2022, at 21:14, Jack Dangler  wrote:

>> Have you tried
>> 
>> python3 hello.py
>
>Will not work on windows. Python is always installed as python.exe and py.exe 
>only.
>

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 "license" for more information.
>>>

C:\Users\Wulfraed>python3.8
Python ActivePython 3.8.2 (ActiveState Software Inc.) based on
 on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

C:\Users\Wulfraed>

C:\Users\Wulfraed>echo %path%
C:\Python38\;C:\Python38\DLLs\;C:\Python38\Scripts\;C:\Python38\Tools\;C:\Python38\Tools\ninja\;C:\Program
Files\PuTTY\;C:\Apps\SQLite3\;C:\Apps\Firebird_4_0;C:\Apps\gnuplot\bin;C:\Apps\R\R-4.0.5\bin\x64;C:\Program
Files
(x86)\SciTE;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
Files\rexx.org\Regina;C:\Apps\Rexx-Extensi


C:\Users\Wulfraed>dir c:\Python38\*.exe
 Volume in drive C is OS
 Volume Serial Number is 4ACC-3CB4

 Directory of c:\Python38

08/25/2020  06:52 PM   998,328 py.exe
08/25/2020  06:53 PM   102,328 python.exe
08/25/2020  06:53 PM   102,336 python3.8.exe
08/25/2020  06:53 PM   102,336 python3.exe
08/25/2020  06:53 PM26,568 pythonservice.exe
08/25/2020  06:53 PM   100,800 pythonw.exe
08/25/2020  06:53 PM   999,352 pyw.exe
10/08/2020  05:24 PM   587,776 Removepywin32.exe
08/25/2020  06:55 PM   123,848 update_check.exe
   9 File(s)  3,143,672 bytes
   0 Dir(s)  650,737,926,144 bytes free

C:\Users\Wulfraed>

Yes, it is an older version of the ActiveState release, but they did
install with the various versioned names. All I had to do was ensure the
directory was on the system PATH.




-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Verifying I installed Python correctly

2022-04-25 Thread Eryk Sun
On 4/25/22, Barry  wrote:
>
>> On 25 Apr 2022, at 21:14, Jack Dangler  wrote:
>
>> Have you tried
>>
>> python3 hello.py
>
> Will not work on windows. Python is always installed as python.exe and
> py.exe only.

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" could be enabled to run 3.9, while
"python3.exe" is enabled to run 3.10. The same applies to the "pip*"
and "idle*" aliases.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Verifying I installed Python correctly

2022-04-25 Thread Barry


> On 25 Apr 2022, at 21:14, Jack Dangler  wrote:
> 
> 
>> On 4/24/22 13:59, Greg wrote:
>> 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 syntax of the command is incorrect.*
>> 
>> I installed version 3.10. I am stuck and could use some help.
>> Thx,
>> 
>> 
>> [image: directory pic.png]
> 
> Have you tried
> 
> python3 hello.py

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

Barry

> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Verifying I installed Python correctly

2022-04-25 Thread Jack Dangler



On 4/24/22 13:59, Greg wrote:

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 syntax of the command is incorrect.*

I installed version 3.10. I am stuck and could use some help.
Thx,


[image: directory pic.png]


Have you tried

python3 hello.py

--
https://mail.python.org/mailman/listinfo/python-list


Re: Verifying I installed Python correctly

2022-04-25 Thread Dennis Lee Bieber
tOn Sun, 24 Apr 2022 13:59:53 -0400, Greg  declaimed the
following:

>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 syntax of the command is incorrect.*
>
>I installed version 3.10. I am stuck and could use some help.
>Thx,
>
>
>[image: directory pic.png]

Text only, no images on this forum.

Cut 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 shown at the start
of a command, is the prompt delimiter) and (normally space separated) is
the output redirection operator when it follows a command.

Your SECOND line, assuming the prompt string is just "C:\Users\gd752>"  is
trying to change directory to a path of "C:\google-python-exercises>" which
is not valid. Take off the trailing >

05/29/2018  09:58 AM  wekafiles
06/18/2020  09:43 PM  workspace_v10
08/23/2018  11:25 AM  workspace_v6_0
01/08/2018  01:45 PM  workspace_v7
07/08/2019  12:10 PM  workspace_v9
  67 File(s)355,065,731 bytes
  44 Dir(s)  650,737,876,992 bytes free

C:\Users\Wulfraed>cd wekafiles>
The syntax of the command is incorrect.

C:\Users\Wulfraed>cd wekafiles

C:\Users\Wulfraed\wekafiles>

Actually, based upon

C:\Users\Wulfraed\wekafiles>cd ..

C:\Users\Wulfraed>cd wekafiles> test.dat

C:\Users\Wulfraed\wekafiles>

the > is acceptable -- AS OUTPUT REDIRECTION, but the your second line does
not specify the target for said redirection (not that CD has much in the
way of output).

This means your first line is attempting to do a CD with output
redirection to a file with a questionable name

C:\Users\Wulfraed>cd wekafiles> python anything.dat
The system cannot find the path specified.


C:\Users\Wulfraed>dir python
 Volume in drive C is OS
 Volume Serial Number is 4ACC-3CB4

 Directory of C:\Users\Wulfraed

04/25/2022  03:29 PM 0 python
   1 File(s)  0 bytes
   0 Dir(s)  650,748,653,568 bytes free

C:\Users\Wulfraed>

It appears to have created a file with the name python, and then failed
attempting to parse the anything.dat


So... To run your script you have two choices...

DIRECT invocation (from anywhere -- hence "prompt" could show anything)
prompt> python C:\google-python-exercises\hello.py

INDIRECT
prompt> cd C:\google-python-exercises
C:\google-python-exercises> python hello.py

(note that the prompt has changed to reflect the CD of the first line)

In neither of those do you ever type a > character.


-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Verifying I installed Python correctly

2022-04-25 Thread Sunil KR via Python-list
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-python-exercises
python hello.py
The error is:  The system cannot find the path specified. If the above version 
of the steps is what you actually performed, I think that by "path" it may be 
referring to the python command. For the system to be able to find python, its 
location should be updated in the "PATH" environment variable. 

If you would rather not distract yourself with modifying the PATH variable you 
can do what Barry says and just use py, because py is installed in a location 
already specified in PATH

If you want to fix your PATH environment variable there is more than one way to 
do this and you may find this out by googling, as you may get a better 
illustrated answer than it would be possible on this forum

Sunil


 

On Monday, April 25, 2022, 10:50:52 AM PDT, Greg  wrote: 
 
 
 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 syntax of the command is incorrect.*

I installed version 3.10. I am stuck and could use some help.
Thx,


[image: directory pic.png]
-- 
https://mail.python.org/mailman/listinfo/python-list
  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Verifying I installed Python correctly

2022-04-25 Thread Barry


> On 25 Apr 2022, at 18:51, Greg  wrote:
> 
> 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.*

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

py hello.py

Barry


> 
> *C:\Users\gd752>cd C:\google-python-exercises>*
> *The syntax of the command is incorrect.*
> 
> I installed version 3.10. I am stuck and could use some help.
> Thx,
> 
> 
> [image: directory pic.png]
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 

-- 
https://mail.python.org/mailman/listinfo/python-list


ANN: eGenix Antispam Bot for Telegram 0.3.0

2022-04-25 Thread eGenix Team


ANNOUNCING

eGenix Antispam Bot for Telegram

   Version 0.3.0

   A simple, yet effective bot implementation
to address Telegram signup spam.

This announcement is also available on our web-site for online reading:
https://www.egenix.com/company/news/eGenix-Antispam-Bot-for-Telegram-0.3.0-GA.html



INTRODUCTION

eGenix has long been running a local user group meeting in Düsseldorf
called Python Meeting Düsseldorf and we are using a Telegram group for
most of our communication.

In the early days, the group worked well and we only had few spammers
joining it, which we could well handle manually.

More recently, this has changed dramatically. We are seeing between 2-5
spam signups per day, often at night. Furthermore, the signups accounts
are not always easy to spot as spammers, since they often come with
profile images, descriptions, etc.

With the bot, we now have a more flexible way of dealing with the
problem.

Please see our project page for details and download links:

https://www.egenix.com/library/telegram-antispam-bot/



FEATURES

 * Low impact mode of operation: the bot tries to keep noise in the
   group to a minimum

 * Several challenge mechanisms to choose from, more can be added as
   needed

 * Flexible and easy to use configuration

 * Only needs a few MB of RAM, so can easily be put into a container or
   run on a Raspberry Pi

 * Can handle quite a bit of load due to the async implementation

 * Works with Python 3.9+

 * MIT open source licensed



NEWS

The 0.3.0 release fixes a few bugs and adds more features:

 * Added new challenge ListItemChallenge

 * Added new config variables MAX_FAILED_CHALLENGES to limit the number
   of failed challenge responses. Defaults to 3.

 * Added docker-compose config example to sources

 * Fixed display of the user name to always show the full name, where
   available.

 * Added work-around for pyrogram to not create session files inside the
   package dir when running the bot in -m mode

 * Fixed bug to make file logging work

 * Fixed bug in ban time handling; this now works correctly

It has been battle-tested in production for more than two months already
and is proving to be a really useful tool to help with Telegram group
administration.

___

INFORMATION

About eGenix (http://www.egenix.com/):

eGenix is a database focused software project, consulting and
product company delivering expert services and professional
quality products for companies, Python users and developers.

About Python (http://www.python.org/):

Python is an object-oriented Open Source programming language
which runs on all modern platforms. By integrating ease-of-use,
clarity in coding, enterprise application connectivity and rapid
application design, Python establishes an ideal programming
platform for today's IT challenges.

Enjoy,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Apr 25 2022)
>>> Python Projects, Coaching and Support ...https://www.egenix.com/
>>> Python Product Development ...https://consulting.egenix.com/


::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   https://www.egenix.com/company/contact/
 https://www.malemburg.com/


-- 
https://mail.python.org/mailman/listinfo/python-list


Verifying I installed Python correctly

2022-04-25 Thread 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 syntax of the command is incorrect.*

I installed version 3.10. I am stuck and could use some help.
Thx,


[image: directory pic.png]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Receive a signal when waking or suspending?

2022-04-25 Thread Skip Montanaro
> https://duckduckgo.com/?t=ffab=python+up+time pointed-out the
> "uptime — Cross-platform uptime library"
> - TLDR; I'm not sure if "uptime" and "boot" relate only to a
> 'cold-start' or if they include bringing the machine out of 'stand-by'
> or 'hibernation'

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://duckduckgo.com/?t=ffab=python+battery+status pointed-out
> several ideas which require MS-Windows, but apparently the psutil
> library could be bent to your will:
>
https://www.geeksforgeeks.org/python-script-to-shows-laptop-battery-percentage/

I actually already have psutil installed. It gives you details about
various system bits (like battery status, which is why I installed it). It
doesn't seem to have anything that will notify about state changes, just
the current state (or — for example — continuous values like the battery
state of charge). I didn't see anything regarding wake/suspend, but I might
have missed it. Since my tool can't run while the system is suspended, it
would always see the system as "awake" but not know for how long it was in
that state. (I'm sure I could track in my tick routine and pay attention to
unusually long gaps.)

I think Marco's response gives me a bit better handle on what I need(*). Maybe
just an easier way to do things. For example, just before suspending and
just after waking, all scripts in /usr/lib/systemd/system-sleep/ are
executed. The only difference is the arguments with which they are called.
A script to suit my needs can just write a stream of records with
timestamps. It took just a minute or so:

#!/bin/sh

echo "`date --iso-8601=seconds` $1 $2" >> /tmp/suspensions
chmod 0644 /tmp/suspensions

Here's what /tmp/suspensions looks like after a couple cycles:

root@montanaro:/usr/lib/systemd/system-sleep# cat /tmp/suspensions
2022-04-23T19:17:41-05:00 pre suspend
2022-04-23T19:17:54-05:00 post suspend
2022-04-23T19:18:48-05:00 pre suspend
2022-04-23T19:19:04-05:00 post suspend


My tool can monitor that file for changes and keep track of the times of
state changes. It can thus track rest intervals across system suspensions
and know if I've been resting for a long enough period of time to allow me
to subject my wrists to further agony
 with
the keyboard and mouse.

Skip

(*) man systemd-sleep contains this admonition:

Note that scripts or binaries dropped in /lib/systemd/system-sleep/ are
intended for local use only and *should be considered hacks*. If
applications want to react to system suspend/hibernation and resume,
they should
rather use the Inhibitor interface[1].


A hack should suit my needs just fine. I'll leave more elegant solutions to
others. :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why no list as dict key?

2022-04-25 Thread Lars Liedtke

Thx, didn't see it that way yet.


--
Lars Liedtke
Software Entwickler


Phone:  
Fax:+49 721 98993-
E-mail: l...@solute.de


solute GmbH
Zeppelinstraße 15   
76185 Karlsruhe
Germany


Marken der solute GmbH | brands of solute GmbH
billiger.de | Shopping.de 



Geschäftsführer | Managing Director: Dr. Thilo Gans, Bernd Vermaaten
Webseite | www.solute.de
Sitz | Registered Office: Karlsruhe
Registergericht | Register Court: Amtsgericht Mannheim
Registernummer | Register No.: HRB 110579
USt-ID | VAT ID: DE234663798


Informationen zum Datenschutz | Information about privacy policy
http://solute.de/ger/datenschutz/grundsaetze-der-datenverarbeitung.php

Am 25.04.22 um 15:54 schrieb Peter J. Holzer:

On 2022-04-25 15:13:19 +0200, Lars Liedtke wrote:

May I stupidly ask, why one would want to use an iterable (even immutable)
as dict key?

A string is also an immutable iterable, so this is probably even the
most common case.

As for more complex data structures:

* Tuples or immutable dicts are a good fit if want to group records by
   subset of their attributes (think "group by" in SQL)

* Objects in general are often though of as units, even if they have
   composite values and you might want to look up something by that
   value.

 hp




--
https://mail.python.org/mailman/listinfo/python-list


Re: Why no list as dict key?

2022-04-25 Thread Peter J. Holzer
On 2022-04-25 15:13:19 +0200, Lars Liedtke wrote:
> May I stupidly ask, why one would want to use an iterable (even immutable)
> as dict key?

A string is also an immutable iterable, so this is probably even the
most common case.

As for more complex data structures:

* Tuples or immutable dicts are a good fit if want to group records by
  subset of their attributes (think "group by" in SQL)

* Objects in general are often though of as units, even if they have
  composite values and you might want to look up something by that
  value.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why no list as dict key?

2022-04-25 Thread 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 somehow the same as a tuple. But anyways I still fail to see the 
application for that, which is most propably to ignorance rather than 
criticism.


Cheers

Lars


--
Lars Liedtke
Software Entwickler


Phone:  
Fax:+49 721 98993-
E-mail: l...@solute.de


solute GmbH
Zeppelinstraße 15   
76185 Karlsruhe
Germany


Marken der solute GmbH | brands of solute GmbH
billiger.de | Shopping.de 



Geschäftsführer | Managing Director: Dr. Thilo Gans, Bernd Vermaaten
Webseite | www.solute.de
Sitz | Registered Office: Karlsruhe
Registergericht | Register Court: Amtsgericht Mannheim
Registernummer | Register No.: HRB 110579
USt-ID | VAT ID: DE234663798


Informationen zum Datenschutz | Information about privacy policy
http://solute.de/ger/datenschutz/grundsaetze-der-datenverarbeitung.php

Am 21.04.22 um 07:00 schrieb Chris Angelico:

On Thu, 21 Apr 2022 at 13:23, Abdur-Rahmaan Janhangeer
 wrote:

Assumes checking for object equality before inserting.
If they are they same, do we need different hashes?


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 so must equality. If
you want that, it's easy to do - just create your own object for the
state, rather than using a list. But then you have to use the original
object to look things up, instead of matching by the data.

Hashes are simply a short-hand for equality. That's all.

ChrisA


--
https://mail.python.org/mailman/listinfo/python-list


[Python-announce] ANN: eGenix Antispam Bot for Telegram 0.3.0

2022-04-25 Thread eGenix Team


ANNOUNCING

eGenix Antispam Bot for Telegram

   Version 0.3.0

   A simple, yet effective bot implementation
to address Telegram signup spam.

This announcement is also available on our web-site for online reading:
https://www.egenix.com/company/news/eGenix-Antispam-Bot-for-Telegram-0.3.0-GA.html



INTRODUCTION

eGenix has long been running a local user group meeting in Düsseldorf
called Python Meeting Düsseldorf and we are using a Telegram group for
most of our communication.

In the early days, the group worked well and we only had few spammers
joining it, which we could well handle manually.

More recently, this has changed dramatically. We are seeing between 2-5
spam signups per day, often at night. Furthermore, the signups accounts
are not always easy to spot as spammers, since they often come with
profile images, descriptions, etc.

With the bot, we now have a more flexible way of dealing with the
problem.

Please see our project page for details and download links:

https://www.egenix.com/library/telegram-antispam-bot/



FEATURES

 * Low impact mode of operation: the bot tries to keep noise in the
   group to a minimum

 * Several challenge mechanisms to choose from, more can be added as
   needed

 * Flexible and easy to use configuration

 * Only needs a few MB of RAM, so can easily be put into a container or
   run on a Raspberry Pi

 * Can handle quite a bit of load due to the async implementation

 * Works with Python 3.9+

 * MIT open source licensed



NEWS

The 0.3.0 release fixes a few bugs and adds more features:

 * Added new challenge ListItemChallenge

 * Added new config variables MAX_FAILED_CHALLENGES to limit the number
   of failed challenge responses. Defaults to 3.

 * Added docker-compose config example to sources

 * Fixed display of the user name to always show the full name, where
   available.

 * Added work-around for pyrogram to not create session files inside the
   package dir when running the bot in -m mode

 * Fixed bug to make file logging work

 * Fixed bug in ban time handling; this now works correctly

It has been battle-tested in production for more than two months already
and is proving to be a really useful tool to help with Telegram group
administration.

___

INFORMATION

About eGenix (http://www.egenix.com/):

eGenix is a database focused software project, consulting and
product company delivering expert services and professional
quality products for companies, Python users and developers.

About Python (http://www.python.org/):

Python is an object-oriented Open Source programming language
which runs on all modern platforms. By integrating ease-of-use,
clarity in coding, enterprise application connectivity and rapid
application design, Python establishes an ideal programming
platform for today's IT challenges.

Enjoy,
-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Apr 25 2022)
>>> Python Projects, Coaching and Support ...https://www.egenix.com/
>>> Python Product Development ...https://consulting.egenix.com/


::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   https://www.egenix.com/company/contact/
 https://www.malemburg.com/


___
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/
Member address: arch...@mail-archive.com