Re: in Python: (101 102 103 201 202 203 301 302 303 401 402 403 )

2024-06-18 Thread Peter J. Holzer via Python-list
On 2024-06-14 06:10:06 -, candycanearter07 via Python-list wrote: > Phil Carmody wrote at 12:01 this Thursday (GMT): > > I'd say you can't beat the verbosity, or lack thereof of just plain > > zsh/bash: > > $ echo {1,2,3,4}0{1,2,3} > > 101 102 103 201 202 203 301 302 303 401 402 403 > >

Re: in Python: (101 102 103 201 202 203 301 302 303 401 402 403 )

2024-06-14 Thread candycanearter07 via Python-list
Phil Carmody wrote at 12:01 this Thursday (GMT): > Paul Rubin writes: >> HenHanna writes: >>> is there another (simple) way to write this? >> >> Yes, but please consider doing these easy exercises yourself instead of >> fobbing them onto other people. > > Hen's probably just an experimental GPT.

Re: in Python: (101 102 103 201 202 203 301 302 303 401 402 403 )

2024-06-13 Thread Phil Carmody via Python-list
Paul Rubin writes: > HenHanna writes: >> is there another (simple) way to write this? > > Yes, but please consider doing these easy exercises yourself instead of > fobbing them onto other people. Hen's probably just an experimental GPT. You, with your limited resources, can never train it. I'd

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))

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

2024-06-11 Thread AVI GROSS via Python-list
#x27;, 'c', 'c'], ['singleton']] >>> chunkC([1, 2, 2, 'c', 'c', 'c', 'singleton']) [[1, 1], [2, 2], ['c', 3], ['singleton', 1]] # COMMENTS The current version has flaws I have not bothered correcting. Jus

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

2024-06-11 Thread Rob Cliffe via Python-list
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 out

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

2024-06-10 Thread AVI GROSS via Python-list
M To: python-list@python.org Subject: Re: in Python? -- Chunk -- (ChunkC '(a a b b b)), ==> ((a 2) (b 3)) 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

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 s

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)

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

2024-06-09 Thread AVI GROSS via Python-list
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 wou

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

2024-06-09 Thread AVI GROSS via Python-list
HH, Before bothering, it might be helpful if you spelled out a bit more in the way of requirements that would satisfy you and perhaps show your attempts. Your examples suggest it would be fairly simple to create an iterator, for example, that would yield as it examined one item at a time until it

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

2024-06-09 Thread MRAB via Python-list
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 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)) (

Re: In Python and Windows environment how to supress certain key press and send some other key event for it

2017-04-23 Thread J. Clarke
In article , i.am.song...@gmail.com says... > > Hi All, > > I was trying to build a VIM like shortcuts in windows. For example, > > IF i press CAPSLOCK & h: It should "{Left}" move one to left. If CAPSLOCK & > b: It should "{Ctrl Down}{Left}{Ctrl Up}" move one word left etc. > > I was successf

Re: In Python 3, how to append a nested dictionary to a shelve file with the added difficulty of using a for loop?

2015-12-22 Thread Peter Otten
Aaron Christensen wrote: > Thanks for the response! Several things you stated definitely got me > thinking. I really appreciate the response. I used what you said and I > am able to accomplish what I needed. Perhaps it becomes clearer when you write two helper functions def read_record(key):

Re: In Python 3, how to append a nested dictionary to a shelve file with the added difficulty of using a for loop?

2015-12-21 Thread Aaron Christensen
Hi Peter, Thanks for the response! Several things you stated definitely got me thinking. I really appreciate the response. I used what you said and I am able to accomplish what I needed. Thanks! Aaron On Mon, Dec 21, 2015 at 7:23 PM, Peter Otten <__pete...@web.de> wrote: > Aaron Christense

Re: In Python 3, how to append a nested dictionary to a shelve file with the added difficulty of using a for loop?

2015-12-21 Thread Peter Otten
Aaron Christensen wrote: > Hello, > > I am trying to figure out how to populate a shelve file with a nested > dictionary. > > These are my requirements: > > -Create shelve file called people.db > -Append the shelve file with new people (person_1, person_2, etc.). > -Use a for loop to iterate th

Re: "**" in python

2014-12-15 Thread Steven D'Aprano
Albert van der Horst wrote: > With some perseverance, you can ask the interpreter what `` ** '' > does: > > help(**) > > maybe so? > help('**') > Indeed, a whole description. Yes! Well spotted! -- Steven -- https://mail.python.org/mailman/listinfo/python-list

Re: "**" in python

2014-12-15 Thread Albert van der Horst
In article , Skip Montanaro wrote: >-=-=-=-=-=- > >I want to add one more thing to the other responses. People new to Python >often seem unaware that being an interpreted language, often the best way >to figure something out is to simply try it at the interpreter prompt. The >OP saw "var ** 2" in

Re: "**" in python

2014-11-23 Thread Sturla Molden
Abdul Abdul wrote: > Wxy**2 > > What do ** mean here? Exponentiation. Same as ** means in Fortran. Sturla -- https://mail.python.org/mailman/listinfo/python-list

Re: "**" in python

2014-11-23 Thread Chris Angelico
On Mon, Nov 24, 2014 at 3:47 PM, Steven D'Aprano wrote: > Hmmm, it appears that ** is a no-op that always returns its left hand > argument: > > py> -1**12 > -1 Ahh but you see, you misunderstand how the whole negative-numbers thing works. You have your syntax wrong. Python was developed by an acc

Re: "**" in python

2014-11-23 Thread Steven D'Aprano
On Sun, 23 Nov 2014 19:48:50 -0600, Skip Montanaro wrote: > I want to add one more thing to the other responses. People new to > Python often seem unaware that being an interpreted language, often the > best way to figure something out is to simply try it at the interpreter > prompt. The OP saw "v

Re: "**" in python

2014-11-23 Thread llanitedave
On Sunday, November 23, 2014 5:49:05 PM UTC-8, Skip Montanaro wrote: > I want to add one more thing to the other responses. People new to Python > often seem unaware that being an interpreted language, often the best way to > figure something out is to simply try it at the interpreter prompt. The

Re: "**" in python

2014-11-23 Thread Skip Montanaro
I want to add one more thing to the other responses. People new to Python often seem unaware that being an interpreted language, often the best way to figure something out is to simply try it at the interpreter prompt. The OP saw "var ** 2" in done code. The most obvious thing to me would have been

Re: "**" in python

2014-11-23 Thread Dan Stromberg
On Sun, Nov 23, 2014 at 5:00 PM, Cameron Simpson wrote: > On 23Nov2014 18:43, Tim Chase wrote: >> >> On 2014-11-24 01:33, Abdul Abdul wrote: >>> >>> Wxy**2 >>> >>> What do ** mean here? >> >> >> "to the power of", so your code squares the value of "Wxy", or "Wxy * >> Wxy" >> >> https://docs.pytho

Re: "**" in python

2014-11-23 Thread Cameron Simpson
On 23Nov2014 18:43, Tim Chase wrote: On 2014-11-24 01:33, Abdul Abdul wrote: Wxy**2 What do ** mean here? "to the power of", so your code squares the value of "Wxy", or "Wxy * Wxy" https://docs.python.org/2/reference/expressions.html#the-power-operator With respect to finding this out for

Re: "**" in python

2014-11-23 Thread Mark Lawrence
On 24/11/2014 00:33, Abdul Abdul wrote: Hello, I came across an example that showed the following: Wxy**2 What do ** mean here? Thanks. You can find out about these by going to https://docs.python.org/3/genindex.html and clicking on 'Symbols' which takes you to https://docs.python.org/3

Re: "**" in python

2014-11-23 Thread Tim Chase
On 2014-11-24 01:33, Abdul Abdul wrote: > Wxy**2 > > What do ** mean here? "to the power of", so your code squares the value of "Wxy", or "Wxy * Wxy" https://docs.python.org/2/reference/expressions.html#the-power-operator -tkc -- https://mail.python.org/mailman/listinfo/python-list

Re: In Python language, what is (void) referring to?

2013-09-21 Thread Steven D'Aprano
On Sat, 21 Sep 2013 02:10:49 -0700, Don Sylvia wrote: > void...? In Python, void doesn't mean anything. [steve@ando ~]$ python Python 2.7.2 (default, May 18 2012, 18:25:10) [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2 Type "help", "copyright", "credits" or "license" for more informa

Re: In Python language, what is (void) referring to?

2013-09-21 Thread Chris Angelico
On Sat, Sep 21, 2013 at 7:10 PM, Don Sylvia wrote: > void...? > -- > https://mail.python.org/mailman/listinfo/python-list That looks like a C-style cast, though casting to void is unusual. If you're looking at the source code to CPython, you might find something like that. In C it usually

Re: In Python language, what is (void) referring to?

2013-09-21 Thread Chris “Kwpolska” Warrick
On Sat, Sep 21, 2013 at 11:10 AM, Don Sylvia wrote: > void...? > -- > https://mail.python.org/mailman/listinfo/python-list void does not exist in Python, unless you named a variable “void”. In that case, it means whatever you set it to. -- Chris “Kwpolska” Warrick

Re: In Python 2.x, is it possible to make unicode as default like in Python 3.x?

2011-06-08 Thread Benjamin Kaplan
On Wed, Jun 8, 2011 at 11:22 AM, G00gle and Python Lover wrote: > Hello. > I almost like everything in Python. Code shrinking, logic of processes, > libraries, code design etc. > But, we... - everybody knows that Python 2.x has lack of unicode support. > In Python 3.x, this has been fixed :) And I

Re: In python CGI, how to pass "hello" back to a javascript function as an argument at client side?

2009-10-13 Thread Piet van Oostrum
> zxo102 (z) wrote: >z> Hi everyone, >z> How can I pass a string generated from python cgi at server side >z> to a >z> javascript function as an argument at client side? >z> I want test.py to "return" a "hello" back so the javascript function >z> load takes "hello" as argument like lo

Re: In python CGI, how to pass "hello" back to a javascript function as an argument at client side?

2009-10-13 Thread Bruno Desthuilliers
zxo102 a écrit : Hi everyone, How can I pass a string generated from python cgi at server side to a javascript function as an argument at client side? This is common HTTP / javascriot stuff - nothing related to Python. First learn about the HTTP protocol - something you obviously need if

Re: In Python 2.6, bytes is str

2008-10-07 Thread Christian Heimes
Bryan Olson wrote: Python 3 has the 'bytes' type, which the string type I've long wanted in various languages. Among other advantages, it is immutable, and therefore bytes objects can be dict keys. There's a mutable version too, called "bytearray". In Python 2.6, the name 'bytes' is defined

Re: In Python 2.6, bytes is str

2008-10-06 Thread Benjamin Kaplan
On Mon, Oct 6, 2008 at 1:30 AM, Bryan Olson <[EMAIL PROTECTED]> wrote: > > > In Python 2.6, the name 'bytes' is defined, and bound to str. The 2.6 > assignment presents some pitfalls. Be aware. > > Consider constructing a bytes object as: > >b = bytes([68, 255, 0]) > > In Python 3.x, len(b) wi

Re: * in Python

2006-06-24 Thread placid
Bruno Desthuilliers wrote: > placid wrote: > > Bruno Desthuilliers wrote: > > > (snip) > >>Why don't you try by yourself in the Python shell ? One of the nice > >>things with Python is that it's quite easy to explore and experiment. > > > > > > i did try it in a Python shell after i learnt what i

Re: * in Python

2006-06-23 Thread Bruno Desthuilliers
placid wrote: > Bruno Desthuilliers wrote: > (snip) >>Why don't you try by yourself in the Python shell ? One of the nice >>things with Python is that it's quite easy to explore and experiment. > > > i did try it in a Python shell after i learnt what it was. Like i said > *args will be a list,

Re: * in Python

2006-06-23 Thread Bruno Desthuilliers
Duncan Booth wrote: > Bruno Desthuilliers wrote: > > >>>so * basically means that args is a list >> >>A tuple IIRC > > > In a function definition * means that any remaining position arguments will > be passed in as a tuple. In a function call the * means that any sequence > will be unpacked a

Re: * in Python

2006-06-23 Thread Duncan Booth
placid wrote: > i did try it in a Python shell after i learnt what it was. Like i said > *args will be a list, but when i try **args with the following code it > doesnt work > > def test(**args): > keys = args.keys() > for key in keys: > print key+"="+args(key) > When you post

Re: * in Python

2006-06-23 Thread placid
Bruno Desthuilliers wrote: > placid wrote: > > Duncan Booth wrote: > > > >>placid wrote: > >> > >> > >>>Hi all, > >>> > >>>Can someone tell me what * in the following code means/does a Google > >>>search didnt turn up anything as i dont know what the * is called > >>>(related to Python and i dont

Re: * in Python

2006-06-23 Thread Duncan Booth
Bruno Desthuilliers wrote: >> so * basically means that args is a list > > A tuple IIRC In a function definition * means that any remaining position arguments will be passed in as a tuple. In a function call the * means that any sequence will be unpacked as positional arguments: it doesn't hav

Re: * in Python

2006-06-23 Thread Bruno Desthuilliers
placid wrote: > Duncan Booth wrote: > >>placid wrote: >> >> >>>Hi all, >>> >>>Can someone tell me what * in the following code means/does a Google >>>search didnt turn up anything as i dont know what the * is called >>>(related to Python and i dont think Python has pointers) >>> >> >>* is for vari

Re: * in Python

2006-06-23 Thread placid
Duncan Booth wrote: > placid wrote: > > > Hi all, > > > > Can someone tell me what * in the following code means/does a Google > > search didnt turn up anything as i dont know what the * is called > > (related to Python and i dont think Python has pointers) > > > * is for variable number of positi

Re: * in Python

2006-06-23 Thread Duncan Booth
placid wrote: > Hi all, > > Can someone tell me what * in the following code means/does a Google > search didnt turn up anything as i dont know what the * is called > (related to Python and i dont think Python has pointers) > * is for variable number of positional arguments, ** is for variable

Re: * in Python

2006-06-23 Thread Fredrik Lundh
placid wrote: > Can someone tell me what * in the following code means/does a Google > search didnt turn up anything as i dont know what the * is called see sections 4.7.2 and 4.7.3 in the tutorial: http://docs.python.org/tut/node6.html#SECTION00674 for more details, see th

Re: in python , could I accomplish the purpose that "a=Console.read()" used in C?

2006-06-05 Thread Bruno Desthuilliers
Ravi Teja a écrit : > Bruno Desthuilliers wrote: > >>python a écrit : >> >>>in python , could I accomplish the purpose that "a=Console.read()" used >>>in C? >> >> >>There's nothing like "Console.read()" in ansi-C. >> > > > He probably got it mixed up with C# which ( almost - Console.Read() ) > h

Re: in python , could I accomplish the purpose that "a=Console.read()" used in C?

2006-06-05 Thread Ravi Teja
Bruno Desthuilliers wrote: > python a écrit : > > in python , could I accomplish the purpose that "a=Console.read()" used > > in C? > > > There's nothing like "Console.read()" in ansi-C. > He probably got it mixed up with C# which ( almost - Console.Read() ) has that. -- http://mail.python.or

Re: in python , could I accomplish the purpose that "a=Console.read()" used in C?

2006-06-04 Thread Dennis Benzinger
python wrote: > in python , could I accomplish the purpose that "a=Console.read()" used > in C? > when program is running, I wanna add a statement like > "a=Console.read()" in C language,it will wait for user's input, after > user's typing a character , and click "enter" key, the program will go >

Re: ?: in Python

2005-12-17 Thread Andy Leszczynski
Steven D'Aprano wrote: > On Wed, 14 Dec 2005 20:17:28 -0500, Andy Leszczynski wrote: > > >>I can tell you what is not elegant in the if else: approach. It is >>logically a one operation while you are forced to use varaible "a" >>twice. Fundamental flaw IMO. > > > "Logically" one operation? >

Re: ?: in Python

2005-12-15 Thread Kent Johnson
Andy Leszczynski wrote: > How can do elegantly in Python: > > if condition: >a=1 > else: >a=2 > > like in C: > > a=condition?1:2 > a = condition and A or B is concise but will fail if A can evaluate as false, e.g. a = condition and None or 2 # won't do what you want I tend to use 'con

Re: in Python

2005-12-15 Thread Andrew Koenig
"Andy Leszczynski" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > How can do elegantly in Python: > > if condition: >a=1 > else: >a=2 I believe that before long Python will support a=1 if condition else 2 -- http://mail.python.org/mailman/listinfo/python-list

Re: ?: in Python

2005-12-15 Thread Steven D'Aprano
On Wed, 14 Dec 2005 20:17:28 -0500, Andy Leszczynski wrote: > I can tell you what is not elegant in the if else: approach. It is > logically a one operation while you are forced to use varaible "a" > twice. Fundamental flaw IMO. "Logically" one operation? def twenty_countries_in_seven_days_bus

Re: ?: in Python

2005-12-15 Thread Dave Hansen
On Wed, 14 Dec 2005 21:16:23 +0100 in comp.lang.python, Lawrence Oluyede <[EMAIL PROTECTED]> wrote: >Il 2005-12-14, Andy Leszczynski <[EMAIL PROTECTED]> ha scritto: >> How can do elegantly in Python: >> >> if condition: >> a=1 >> else: >> a=2 >> >> like in C: >> >> a=condition?1:2 >> > >Th

Re: ?: in Python

2005-12-14 Thread Steven Bethard
Andy Leszczynski wrote: > How can do elegantly in Python: > > if condition: >a=1 > else: >a=2 > > like in C: > > a=condition?1:2 Step (1): Wait for Python 2.5[1] Step (2): Write the code:: a = 1 if condition else 2 STeVe [1]http://www.python.org/peps/pep-0308.html -- http://mai

Re: ?: in Python

2005-12-14 Thread Andy Leszczynski
Steven D'Aprano wrote: > On Wed, 14 Dec 2005 14:09:10 -0500, Andy Leszczynski wrote: > > >>How can do elegantly in Python: >> >>if condition: >>a=1 >>else: >>a=2 >> >>like in C: >> >>a=condition?1:2 > > > I thought you wanted to do it *elegantly*? > > Your first solution is perfectly e

Re: ?: in Python

2005-12-14 Thread bonono
Andy Leszczynski wrote: > How can do elegantly in Python: > > if condition: > a=1 > else: > a=2 > > like in C: > > a=condition?1:2 a=(condition and [1] or [2])[0] For this simple snippet, I don't think it is better than if/else, But you can use it in map/reduce or list comprehension/gene

Re: ?: in Python

2005-12-14 Thread Steven D'Aprano
On Wed, 14 Dec 2005 14:09:10 -0500, Andy Leszczynski wrote: > How can do elegantly in Python: > > if condition: > a=1 > else: > a=2 > > like in C: > > a=condition?1:2 I thought you wanted to do it *elegantly*? Your first solution is perfectly elegant to my eyes, unlike that horrible C

Re: ?: in Python

2005-12-14 Thread Peter Hansen
Andy Leszczynski wrote: > Lawrence Oluyede wrote: >>There are tons of threads on this newsgroup and in the python-dev mailing >>list about a ternary operator. There's also a PEP AFAIK. >> >>I like this: >> >>In [1]:switch = True >> >>In [2]:a = (1, 2)[switch] >> >>In [3]:print a >>2 > > Like it to

Re: ?: in Python

2005-12-14 Thread gene tani
Andy Leszczynski wrote: > How can do elegantly in Python: > > if condition: > a=1 > else: > a=2 > > like in C: > > a=condition?1:2 google for ternary operator http://www.python.org/doc/faq/programming.html#is-there-an-equivalent-of-c-s-ternary-operator http://www.norvig.com/python-iaq.ht

Re: ?: in Python

2005-12-14 Thread Bengt Richter
On Wed, 14 Dec 2005 21:16:23 +0100, Lawrence Oluyede <[EMAIL PROTECTED]> wrote: >Il 2005-12-14, Andy Leszczynski <[EMAIL PROTECTED]> ha scritto: >> How can do elegantly in Python: >> >> if condition: >> a=1 >> else: >> a=2 >> >> like in C: >> >> a=condition?1:2 >> > >There are tons of thre

Re: ?: in Python

2005-12-14 Thread Andy Leszczynski
Lawrence Oluyede wrote: > Il 2005-12-14, Andy Leszczynski <[EMAIL PROTECTED]> ha scritto: > >>How can do elegantly in Python: >> >>if condition: >>a=1 >>else: >>a=2 >> >>like in C: >> >>a=condition?1:2 >> > > > There are tons of threads on this newsgroup and in the python-dev mailing > l

Re: ?: in Python

2005-12-14 Thread Lawrence Oluyede
Il 2005-12-14, Andy Leszczynski <[EMAIL PROTECTED]> ha scritto: > How can do elegantly in Python: > > if condition: > a=1 > else: > a=2 > > like in C: > > a=condition?1:2 > There are tons of threads on this newsgroup and in the python-dev mailing list about a ternary operator. There's also