Re: Bringing Order to programming

2019-01-31 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > source = \ > 'Python is an easy to learn, powerful programming language. It has' + \ > ' efficient high-level data structures and a simple but effective' + \ > ' approach to object-oriented programming. Python's elegant syntax' + \ You have an unexsc

Re: Bringing Order to programming

2019-01-31 Thread Chris Angelico
On Fri, Feb 1, 2019 at 2:00 PM MRAB wrote: > > On 2019-02-01 00:28, Avi Gross wrote: > > The second variant is to use the newer bytearray data structure very > > carefully as it is to a first approximation a mutable string. Adding to the > > end of a new one should be quick. WARNING: I said be car

Re: Bringing Order to programming

2019-01-31 Thread MRAB
On 2019-02-01 00:28, Avi Gross wrote: The discussion moved on to debating if an algorithm is O(N) or O(N**2). For small amounts of text, on fast machines, it really is not worth worrying about the cost of appending to the end of a growing string resulting in multiple copies and lots of garbage c

Bringing Order to programming

2019-01-31 Thread Avi Gross
The discussion moved on to debating if an algorithm is O(N) or O(N**2). For small amounts of text, on fast machines, it really is not worth worrying about the cost of appending to the end of a growing string resulting in multiple copies and lots of garbage collection. Many computer textbooks love

Re: Trying to figure out the data type from the code snippet

2019-01-31 Thread Terry Reedy
On 1/31/2019 3:31 PM, Chupo via Python-list wrote: In article , Chris Angelico says... There are stupid questions, but I enjoy answering those too. You don't need to apologize for asking these questions. All you need to do is ignore the trolls like Rick. In fact, if you abandon Google Groups an

Re: How to replace space in a string with \n

2019-01-31 Thread Terry Reedy
On 1/31/2019 1:36 PM, Grant Edwards wrote: On 2019-01-31, Grant Edwards wrote: On 2019-01-31, Terry Reedy wrote: On 1/31/2019 11:19 AM, Ian Clark wrote: text = "The best day of my life!" output = '' for i in text: if i == ' ': output +='\n' else: output += i print(output)

Re: Trying to figure out the data type from the code snippet

2019-01-31 Thread DL Neil
On 1/02/19 9:00 AM, Chris Angelico wrote: On Fri, Feb 1, 2019 at 6:56 AM Chupo via Python-list wrote: In article <67d5c4bc-7212-43d0-b44f-7f22efffa...@googlegroups.com>, Rick Johnson says... I was thought there aren't stupid questions, just stupid answers and I for sure won't apologize for

Re: Trying to figure out the data type from the code snippet

2019-01-31 Thread Chupo via Python-list
In article , Rick Johnson says... > You know _all_ that What I mentioned is just a small excerpt of what I know :-) > yet... you didn't know about the built-in `type()` method? Exactly :-) > Well, that's just great. We can only hope you don't try your hand at any > mission-critical code. A

Re: Trying to figure out the data type from the code snippet

2019-01-31 Thread Chupo via Python-list
In article , Chris Angelico says... > Ah okay. You may want to killfile a few people then, since you're > using an actual real newsreader and have that capability. > Yes, Gravity has Bozo Bin for that purpose :-) But although I've been using newsgroups for 20 years I've never blocked a single

Re: Trying to figure out the data type from the code snippet

2019-01-31 Thread Chupo via Python-list
In article , Chris Angelico says... > There are stupid questions, but I enjoy answering those too. You don't > need to apologize for asking these questions. All you need to do is > ignore the trolls like Rick. In fact, if you abandon Google Groups and > instead read the mailing list python-list@p

Re: Trying to figure out the data type from the code snippet

2019-01-31 Thread Chris Angelico
On Fri, Feb 1, 2019 at 7:36 AM Chupo via Python-list wrote: > > In article , Chris > Angelico says... > > There are stupid questions, but I enjoy answering those too. You don't > > need to apologize for asking these questions. All you need to do is > > ignore the trolls like Rick. In fact, if you

Re: Trying to figure out the data type from the code snippet

2019-01-31 Thread Chupo via Python-list
> I was thought > I meant: 'I was taught'. -- Let There Be Light Custom LED driveri prema specifikacijama http://tinyurl.com/customleddriver Chupo -- https://mail.python.org/mailman/listinfo/python-list

Re: Trying to figure out the data type from the code snippet

2019-01-31 Thread Chris Angelico
On Fri, Feb 1, 2019 at 6:56 AM Chupo via Python-list wrote: > > In article <67d5c4bc-7212-43d0-b44f-7f22efffa...@googlegroups.com>, > Rick Johnson says... > > > > > I'm impressed! But you're asking basic questions that someone with your > > resume should either (1) already know, or (2) be compe

Re: Trying to figure out the data type from the code snippet

2019-01-31 Thread Chupo via Python-list
In article <67d5c4bc-7212-43d0-b44f-7f22efffa...@googlegroups.com>, Rick Johnson says... > I'm impressed! But you're asking basic questions that someone with your > resume should either (1) already know, or (2) be competent enough to find on > their own. Now don't get me wrong. My intention

Re: How to replace space in a string with \n

2019-01-31 Thread Neil Cerutti
On 2019-01-31, ^Bart wrote: > Hello everybody! :) > > I got a text and I should replace every space with \n without to use > str.replace, I thought something like this: > > text = "The best day of my life!" > > space = (' ') > > if text.count(' ') in text: > space=\n > > rightText = text-spa

Re: How to replace space in a string with \n

2019-01-31 Thread Grant Edwards
On 2019-01-31, ^Bart wrote: > Hello everybody! :) > > I got a text and I should replace every space with \n without to use > str.replace, I thought something like this: > > text = "The best day of my life!" [...] > I should have an output like this: > The > best > day > of > my > life! Here's

Re: How to replace space in a string with \n

2019-01-31 Thread Chris Angelico
On Fri, Feb 1, 2019 at 5:34 AM Grant Edwards wrote: > > On 2019-01-31, Terry Reedy wrote: > > On 1/31/2019 11:19 AM, Ian Clark wrote: > >> text = "The best day of my life!" > >> output = '' > >> > >> for i in text: > >> if i == ' ': > >>output +='\n' > >> else: > >>output += i > >> >

Re: How to replace space in a string with \n

2019-01-31 Thread Grant Edwards
On 2019-01-31, Grant Edwards wrote: > On 2019-01-31, Terry Reedy wrote: >> On 1/31/2019 11:19 AM, Ian Clark wrote: >>> text = "The best day of my life!" >>> output = '' >>> >>> for i in text: >>> if i == ' ': >>>output +='\n' >>> else: >>>output += i >>> >>> print(output) > >> But t

Re: How to replace space in a string with \n

2019-01-31 Thread Grant Edwards
On 2019-01-31, Terry Reedy wrote: > On 1/31/2019 11:19 AM, Ian Clark wrote: >> text = "The best day of my life!" >> output = '' >> >> for i in text: >> if i == ' ': >>output +='\n' >> else: >>output += i >> >> print(output) > But this is an awful, O(n*n) way to solve an inherently O

Re: How to replace space in a string with \n

2019-01-31 Thread Terry Reedy
On 1/31/2019 11:19 AM, Ian Clark wrote: text = "The best day of my life!" output = '' for i in text: if i == ' ': output +='\n' else: output += i print(output) throwing my hat in the ring, not only is it .replace free it is entirely method free But this is an awful, O(n*n) way to s

RE: How to replace space in a string with \n

2019-01-31 Thread Avi Gross
It is amazing to watch what happens when a fairly simple question is asked to see how people answer. In an effort not to ramble, I will summarize my thoughts. The student wanted to know how to solve a problem using only what they already should know and that specifically they should not use a meth

Re: How to replace space in a string with \n

2019-01-31 Thread Ian Clark
text = "The best day of my life!" output = '' for i in text: if i == ' ': output +='\n' else: output += i print(output) throwing my hat in the ring, not only is it .replace free it is entirely method free On Thu, Jan 31, 2019 at 3:41 AM ^Bart wrote: > [Solved by myself and I'm happy!!!

Re: How to replace space in a string with \n

2019-01-31 Thread ^Bart
[Solved by myself and I'm happy!!! :)] text = "The best day of my life!" space = text[3] print (text.replace(space, "\n")) [Like what I said in another message, in the afternoon I'll ask to the teacher if for this exercise we're able to use .replace] -- https://mail.python.org/mailman/listin

Re: How to replace space in a string with \n

2019-01-31 Thread Michael Poeltl
hi ^Bert, I've just thought that you don't like to use text.replace(' ', '\n'), and so I came up with another way to get the job done. So it was part of a "school-test" - uiuitststs ;-) follow the hint from Peter then, and inside *your* for-loop ask yourself, how to inspect the value of c in a

Re: How to replace space in a string with \n

2019-01-31 Thread Chris Angelico
On Thu, Jan 31, 2019 at 9:56 PM ^Bart wrote: > > >You coulde use »sub« from the module »re«, then. > >(The Python Library Reference, Release 3.8.0a0 - > >6.2 re - Regular expression operations) > > We're using 3.7.2 :\ > Don't worry about that difference - 3.8 is only minorly differen

Re: How to replace space in a string with \n

2019-01-31 Thread Antoon Pardon
On 31/01/19 11:47, ^Bart wrote: >>    . A correct answer to the exercise would be: >> >> |You cannot replace a space with \n in a string, >> |because strings are immutable in Python. > > Yes, I thought in a wrong way! :) > Well maybe you can turn the string into a list of characters. Then replace t

Re: How to replace space in a string with \n

2019-01-31 Thread ^Bart
No it is not the proper way of a school test to copy what others provided. You're right but I need just to understand what tools I should use, it could be nice if the teacher says something like "use just these three tools to solve this problem" or "you don't need to use these other tools to

Re: How to replace space in a string with \n

2019-01-31 Thread ^Bart
You coulde use »sub« from the module »re«, then. (The Python Library Reference, Release 3.8.0a0 - 6.2 re - Regular expression operations) We're using 3.7.2 :\ Otherwise, Write a loop that takes the first character from the source and appends it to a new string until there

Re: How to replace space in a string with \n

2019-01-31 Thread ^Bart
. A correct answer to the exercise would be: |You cannot replace a space with \n in a string, |because strings are immutable in Python. Yes, I thought in a wrong way! :) -- https://mail.python.org/mailman/listinfo/python-list

Re: How to replace space in a string with \n

2019-01-31 Thread ^Bart
Il 31/01/19 10:34, Michael Poeltl ha scritto: hi, Maybe this is a proper way to do what you'd liked to achieve text = "The best day of my life!" newtext = '\n'.join( text.split() ) print(newtext) The best day of my life! yours Michael Thanks Michael, I'll ask to my teacher in the afterno

Re: How to replace space in a string with \n

2019-01-31 Thread ^Bart
Have you even tried to run this? No, it doesn't run, it's just a personal idea! :) I don't think this does what you think it does. text.count(' ') will return 5, an integer. So you are testing if 5 is in text. But since 5 is an integer that will raise a TypeError. Yes, I understood this is

Re: How to replace space in a string with \n

2019-01-31 Thread Antoon Pardon
On 31/01/19 10:37, Michael Poeltl wrote: > hi, > > ^Bart ended in a Mail-Delivery... > so I send it ONLY to the python-list > > ^Bert, a proper way to do what you'd liked to achieve is the following: No it is not the proper way of a school test to copy what others provided. -- Antoon. -- htt

Re: How to replace space in a string with \n

2019-01-31 Thread Antoon Pardon
On 31/01/19 10:18, ^Bart wrote: > Hello everybody! :) > > I got a text and I should replace every space with \n without to use > str.replace, I thought something like this: Have you even tried to run this? > > text = "The best day of my life!" > > space = (' ') > > if text.count(' ') in text: >  

Re: How to replace space in a string with \n

2019-01-31 Thread Peter Otten
^Bart wrote: >> Why? > > It's a school test, now we should use just what we studied, if than, > else, sequences, etc.! > > ^Bart Hint: you can iterate over the characters of a string >>> for c in "hello": ... print(c) ... h e l l o -- https://mail.python.org/mailman/listinfo/python-l

Re: How to replace space in a string with \n

2019-01-31 Thread Michael Poeltl
hi, ^Bart ended in a Mail-Delivery... so I send it ONLY to the python-list ^Bert, a proper way to do what you'd liked to achieve is the following: >>> text = "The best day of my life!" >>> newtext = '\n'.join( text.split() ) >>> print(newtext) The best day of my life! >>> regards Michael * ^B

Re: How to replace space in a string with \n

2019-01-31 Thread Michael Poeltl
hi, Maybe this is a proper way to do what you'd liked to achieve >>> text = "The best day of my life!" >>> newtext = '\n'.join( text.split() ) >>> print(newtext) The best day of my life! >>> yours Michael * ^Bart [2019-01-31 10:22]: > Hello everybody! :) > > I got a text and I should replace e

Re: How to replace space in a string with \n

2019-01-31 Thread Michael Poeltl
maybe this is an alternative way to get your wished result. >>> text = "The best day of my life!" >>> newtext = '\n'.join( text.split() ) >>> print(newtext) The best day of my life! >>> yours Michael * ^Bart [2019-01-31 10:22]: > Hello everybody! :) > > I got a text and I should replace every s

Re: How to replace space in a string with \n

2019-01-31 Thread ^Bart
Why? It's a school test, now we should use just what we studied, if than, else, sequences, etc.! ^Bart -- https://mail.python.org/mailman/listinfo/python-list

Re: How to replace space in a string with \n

2019-01-31 Thread Alister via Python-list
On Thu, 31 Jan 2019 10:18:20 +0100, ^Bart wrote: > Hello everybody! :) > > I got a text and I should replace every space with \n without to use > str.replace, Why? > I thought something like this: > > text = "The best day of my life!" > > space = (' ') > > if text.count(' ') in text: >

EPS: Announcing the Guido van Rossum Core Developer Grant

2019-01-31 Thread M.-A. Lemburg
At the last General Assembly of the EuroPython Society (EPS) at EuroPython 2018 in Edinburgh, we voted on a new grant program we want to put in place for future EuroPython conferences. We all love Python and this is one of the main reasons we are putting on EuroPython year after year, serving the

How to replace space in a string with \n

2019-01-31 Thread ^Bart
Hello everybody! :) I got a text and I should replace every space with \n without to use str.replace, I thought something like this: text = "The best day of my life!" space = (' ') if text.count(' ') in text: space=\n rightText = text-space print(rightText) I should have an output