xkcd.com/353 ( Flying with Python )

2024-04-01 Thread HenHanna via Python-list



https://xkcd.com/353/  ( Flying with  Python )




https://xkcd.com/1306/
 what does  SIGIL   mean?



Other  xkcd   that you like?
--
https://mail.python.org/mailman/listinfo/python-list


Re: xkcd.com/353 ( Flying with Python )

2024-04-01 Thread HenHanna via Python-list

Greg Ewing wrote:


On 30/03/24 7:21 pm, HenHanna wrote:

https://xkcd.com/1306/
  what does  SIGIL   mean?



I think its' a Perl term, referring to the $/@/# symbols in front of
identifiers.
 
 
 
   thanks!


 https://www.explainxkcd.com/wiki/index.php/1306:_Sigil_Cycle
--
https://mail.python.org/mailman/listinfo/python-list


Re: xkcd.com/353 ( Flying with Python )

2024-04-01 Thread HenHanna via Python-list

Johanne Fairchild wrote:


HenHanna  writes:



https://xkcd.com/1306/
 what does  SIGIL   mean?



  A glyph used in magic. Or, for Perl, the symbol in front of a variable
  name, such as $, @, and %.



  Source:   https://perldoc.perl.org/perlglossary#sigil



  Sigil is noun. Definitions:



  A seal; a signet.
  A sign or an image considered magical.
  A seal; a signature.



  Source:  The American Heritage® Dictionary of the English Language, 5th 
Edition.



 
 


omg...Sigil  is a real word???


The word "sigil" comes from the Latin term "sigillum," which means "little sign."  This Latin root is also 
the source of our English word "seal," making "sigil" and "seal" doublets.

 https://en.wiktionary.org/wiki/sigil



__words that we use in Programming   but not Found in a 
real dictionary :

  Camel case ,   int,char,   min,   len,  def,   elseif  


cons, defun,  cond,  goto,
--
https://mail.python.org/mailman/listinfo/python-list


Re: xkcd.com/353 ( Flying with Python )

2024-04-03 Thread HenHanna via Python-list

On 3/29/2024 11:21 PM, HenHanna wrote:


https://xkcd.com/353/  ( Flying with  Python )




https://xkcd.com/1306/

  what does  SIGIL   mean?  -- (i got it...Thanks!)




Other  xkcd   that you like?


my fav. one may be the one about [Bad-ass Hacker] [Nice-ass car].


Does he use Python?   i wonder.


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


Re: xkcd.com/353 ( Flying with Python )

2024-04-03 Thread HenHanna via Python-list

Blue-Maned_Hawk wrote:


HenHanna wrote:



https://xkcd.com/1306/
  what does  SIGIL   mean?


I'd define a sigil as a mandatory symbol used to indicate the properties 
of a name.


 
 
if i'm getting this right...  Sigil is part of the language spec,


whereas (in Lisp in the old days), there was a convention of using var-name like *foo*  to 
  indicate it's a dynamic variable.


and sometimes   **foo**  for 

and %foo%  or   %%foo%%   was used for ...
--
https://mail.python.org/mailman/listinfo/python-list


Cprod -- (writing this: itertools.product([0, 1], repeat=N )

2024-05-21 Thread HenHanna via Python-list



How can i write this function Cprod (Cartesian Product) simply?

(writing this out: itertools.product([0, 1], repeat=N )

The value can be a list or a Tuple.

cprod([0, 1], 1) => ((0) (1))

cprod([0, 1], 2) => ((0,0) (0,1) (1,0) (1,1))



This works:

   def cprod(x, c):
if c==1: return [[i] for i in x]
Sub= cprod(x, c-1)
return [i  for F in x   for i in [[F]+R for R in Sub]]


-- Is there another way to write [F]+R ???

   Other ways to improve it?
--
https://mail.python.org/mailman/listinfo/python-list


Re: Cprod -- (writing this: itertools.product([0, 1], repeat=N )

2024-05-22 Thread HenHanna via Python-list

dn wrote:


On 22/05/24 07:14, HenHanna via Python-list wrote:


How can i write this function Cprod (Cartesian Product) simply?

     (writing this out: itertools.product([0, 1], repeat=N
)

The value can be a list or a Tuple.

     cprod([0, 1], 1) => ((0) (1))

     cprod([0, 1], 2) => ((0,0) (0,1) (1,0) (1,1))



This works:

    def cprod(x, c):
     if c==1: return [[i] for i in x]
     Sub= cprod(x, c-1)
     return [i  for F in x   for i in [[F]+R for R in Sub]]


-- Is there another way to write [F]+R ???

    Other ways to improve it?



https://python.readthedocs.io/en/stable/library/itertools.html#itertools.product
   Regards,  =dn



Thank you...  That code looks elegant...  I'll study it.
--
https://mail.python.org/mailman/listinfo/python-list


Any marginally usable programming language approaches an ill defined barely usable re-implementation of half of Common-Lisp

2024-05-27 Thread HenHanna via Python-list



On 5/27/2024 7:18 AM, Cor wrote:

Some entity, AKA "B. Pym" ,
wrote this mindboggling stuff:
(selectively-snipped-or-not-p)


On 12/16/2023, c...@clsnet.nl wrote:


Any marginally usable programming language approaches an ill
defined barely usable re-implementation of half of common-lisp


The good news is, it's not Lisp that sucks, but Common Lisp.
  --- Paul Graham


Just to set the record straight;
This is not My line.
I quoted it but don't know who the originator of that remark is.

Cor




a few years ago...  when i started learning Python...

 it was so  exciting...

Every day i thought...

--- THis is Lisp in a thin-disguise ... SO  Everyone gets it now.
Everyone is a Lisper now.


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


Re: Any marginally usable programming language approaches an ill defined barely usable re-implementation of half of Common-Lisp

2024-05-29 Thread HenHanna via Python-list



On 5/27/2024 1:59 PM, 2qdxy4rzwzuui...@potatochowder.com wrote:

On 2024-05-27 at 12:37:01 -0700,
HenHanna via Python-list  wrote:



On 5/27/2024 7:18 AM, Cor wrote:

Some entity, AKA "B. Pym" ,
wrote this mindboggling stuff:
(selectively-snipped-or-not-p)


On 12/16/2023, c...@clsnet.nl wrote:


Any marginally usable programming language approaches an ill
 defined barely usable re-implementation of half of common-lisp


The good news is, it's not Lisp that sucks, but Common Lisp.
   --- Paul Graham


Just to set the record straight;
This is not My line.
I quoted it but don't know who the originator of that remark is.


https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule



interesting!!!

Are  the Rules 1--9  by  Greenspun   good too?


  does   Greenspun   pun ?

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


From JoyceUlysses.txt -- words occurring exactly once

2024-05-30 Thread HenHanna via Python-list



Given a text file of a novel (JoyceUlysses.txt) ...

could someone give me a pretty fast (and simple) Python program that'd 
give me a list of all words occurring exactly once?


  -- Also, a list of words occurring once, twice or 3 times



re: hyphenated words(you can treat it anyway you like)

   but ideally, i'd treat  [editor-in-chief]
   [go-ahead]  [pen-knife]
   [know-how]  [far-fetched] ...
   as one unit.
--
https://mail.python.org/mailman/listinfo/python-list


Re: From JoyceUlysses.txt -- words occurring exactly once

2024-05-31 Thread HenHanna via Python-list

On 5/30/2024 2:18 PM, dn wrote:

On 31/05/24 08:03, HenHanna via Python-list wrote:


Given a text file of a novel (JoyceUlysses.txt) ...

could someone give me a pretty fast (and simple) Python program that'd 
give me a list of all words occurring exactly once?


   -- Also, a list of words occurring once, twice or 3 times



re: hyphenated words    (you can treat it anyway you like)

    but ideally, i'd treat  [editor-in-chief]
    [go-ahead]  [pen-knife]
    [know-how]  [far-fetched] ...
    as one unit.





Split into words - defined as you will.
Use Counter.

Show some (of your) code and we'll be happy to critique...



hard to decide what to do with hyphens
   and apostrophes
 (I'd,  he's,  can't, haven't,  A's  and  B's)


2-step-Process

  1. make a file listing all words (one word per line)

  2.  then, doing the counting.  using
  from collections import Counter


Related code  (for 1)  that i'd used before:

 Rfile  = open("JoyceUlysses.txt", 'r')

 with open( 'Out.txt', 'w' ) as fo:
for line in Rfile:
line = line.rstrip()
wLis = line.split()
for w in wLis:
if w != "":
w = w.rstrip(";:,'\"[]()*&^%$#@!,./<>?_-+=")
w = w.lstrip(";:,'\"[]()*&^%$#@!,./<>?_-+=")
fo.write(w.lower())
fo.write('\n')

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


Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )

2024-05-31 Thread HenHanna via Python-list



 ;;;  Pls tell me about little tricks you use in Python or Lisp.


[('the', 36225), ('and', 17551), ('of', 16759), ('i', 16696), ('a', 
15816), ('to', 15722), ('that', 11252), ('in', 10743), ('it', 10687)]


((the 36225) (and 17551) (of 16759) (i 16696) (a 15816) (to 15722) (that 
11252) (in 10743) (it 10687))



i think the latter is easier-to-read, so i use this code
   (by Peter Norvig)

def lispstr(exp):
   # "Convert a Python object back into a Lisp-readable string."
if isinstance(exp, list):
return '(' + ' '.join(map(lispstr, exp)) + ')'
else:
return str(exp)

def Lprint(x): print(lispstr(x))
--
https://mail.python.org/mailman/listinfo/python-list


in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))

2024-06-09 Thread HenHanna via Python-list



Chunk, ChunkC -- nice simple way(s) to write these in Python?


(Chunk  '(a a   ba a a   b b))
==> ((a a) (b)  (a a a) (b b))


(Chunk  '(a a a a   b   c c   a a   d   e e e e))
==> ((a a a a) (b) (c c) (a a) (d) (e e e e))


(Chunk  '(2 2   foo   bar bar   j j j   k   baz baz))
==> ((2 2) (foo) (bar bar) (j j j) (k) (baz baz))

_

(ChunkC  '(a a   b b b))
 ==> ((a 2)  (b 3))

(ChunkC  '(a a   b  a a a   b b))
 ==> ((a 2)  (b 1)  (a 3)   (b 2))
--
https://mail.python.org/mailman/listinfo/python-list


Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))

2024-06-10 Thread HenHanna via Python-list

On 6/9/2024 3:50 PM, MRAB wrote:

On 2024-06-09 22:20, HenHanna via Python-list wrote:


Chunk, ChunkC -- nice simple way(s) to write these in Python?


(Chunk  '(a a   b    a a a   b b))
  ==> ((a a) (b)  (a a a) (b b))


(Chunk  '(a a a a   b   c c   a a   d   e e e e))
  ==> ((a a a a) (b) (c c) (a a) (d) (e e e e))


(Chunk  '(2 2   foo   bar bar   j j j   k   baz baz))
  ==> ((2 2) (foo) (bar bar) (j j j) (k) (baz baz))

_

(ChunkC  '(a a   b b b))
   ==> ((a 2)  (b 3))

(ChunkC  '(a a   b  a a a   b b))
   ==> ((a 2)  (b 1)  (a 3)   (b 2))


You can make use of itertools.groupby.




Thanks!   i'll try it.


Scheme (Gauche)

(use srfi-1)   ; span

(define (gp x)
  (if (null? x) '()
(let-values (((F L) (span (cut equal? (car x) <>) x)))
  (cons F (gp L)

(print (gp   '(ab ba a a   b b b b)))
(print (gp   '(c c c   a   d d d d   a   e e e e e)))

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


Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))

2024-06-10 Thread HenHanna via Python-list

On 6/9/2024 7:05 PM, avi.e.gr...@gmail.com wrote:

I remembered that HenHanna had been hard to deal with in the past and when
my reply to him/her/them bounced as a bad/fake address it came back to me
that I am better off not participating in this latest attempt to get us to
perform then probably shoot whatever we say down.

A considerate person would ask questions more clearly and perhaps explain
what language they are showing us code from and so on.

Life is too short to waste.

-Original Message-
From: Python-list  On
Behalf Of HenHanna via Python-list
Sent: Sunday, June 9, 2024 5:20 PM
To: python-list@python.org
Subject: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))

Chunk, ChunkC -- nice simple way(s) to write these in Python?


(Chunk  '(a a   ba a a   b b))
  ==> ((a a) (b)  (a a a) (b b))


(Chunk  '(a a a a   b   c c   a a   d   e e e e))
  ==> ((a a a a) (b) (c c) (a a) (d) (e e e e))


(Chunk  '(2 2   foo   bar bar   j j j   k   baz baz))
  ==> ((2 2) (foo) (bar bar) (j j j) (k) (baz baz))

_

(ChunkC  '(a a   b b b))
   ==> ((a 2)  (b 3))

(ChunkC  '(a a   b  a a a   b b))
   ==> ((a 2)  (b 1)  (a 3)   (b 2))




i was just curiuos about simple, clever way to write it in Python


in Scheme (Gauche)

(use srfi-1)  ;; span

(define (gp x)
  (if (null? x) '()
(let-values (((F L) (span (cut equal? (car x) <>) x)))
  (cons F (gp L)

(print (gp   '(ab ba a a   b b b b)))
(print (gp   '(c c c   a   d d d d   a   e e e e e)))

(define (gpC x)  (map (lambda (x) (list (car x) (length x))) (gp x)))

(print (gpC '(ab ba a a   b b b b)))
(print (gpC '(c c c   a   d d d d   a   e e e e e)))
--
https://mail.python.org/mailman/listinfo/python-list


Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3))

2024-06-11 Thread HenHanna via Python-list

On 6/10/2024 6:29 AM, Rob Cliffe wrote:

import itertools

def chunk1(seq):
     return [ ch * len(list(grp)) for (ch, grp) in itertools.groupby(s) ]

def chunk2(seq):
     return [ (ch, len(list(grp))) for (ch, grp) in itertools.groupby(s) ]

s='aaabbaa'
print(chunk1(s))
print(chunk2(s))
###
Program output:
['aaa', 'bb', '', 'aa']
[('a', 3), ('b', 2), ('c', 4), ('a', 2)]

Rob Cliffe




thank you...   OMG... For 10 minutes... i was SO mystified by
the question...
How can this code work??? ,  when it's
  > def chunk1(seq):
 and it's  [s]   within the def-body ?

it seemed as if the Compiler was doing a DWIM (Do what i mean)  trick.




On 09/06/2024 22:20, HenHanna via Python-list wrote:


Chunk, ChunkC -- nice simple way(s) to write these in Python?


(Chunk  '(a a   b    a a a   b b))
    ==> ((a a) (b)  (a a a) (b b))


(Chunk  '(a a a a   b   c c   a a   d   e e e e))
    ==> ((a a a a) (b) (c c) (a a) (d) (e e e e))


(Chunk  '(2 2   foo   bar bar   j j j   k   baz baz))
    ==> ((2 2) (foo) (bar bar) (j j j) (k) (baz baz))

_

(ChunkC  '(a a   b b b))
 ==> ((a 2)  (b 3))

(ChunkC  '(a a   b  a a a   b b))
 ==> ((a 2)  (b 1)  (a 3)   (b 2))




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