Re: Function returns old value

2020-12-19 Thread Michael F. Stemper

On 18/12/2020 00.09, Cameron Simpson wrote:

On 17Dec2020 14:22, Michael F. Stemper  wrote:

On 17/12/2020 03.57, Peter J. Holzer wrote:

On 2020-12-17 03:06:32 -, Bischoop wrote:



With newer vims that's rarely necessary though since they can
distinguish
between input that was pasted and input that was typed.


Mine doesn't seem to (vim inside a MacOS iTerm).


I thought that I was going nuts when I encountered that. Any idea how to
defeat such a so-called 'feature"?


You mean having vim figure that out? I dunno. I came here from vi and
haven't fully embraced al the stuff vim has.


What I want is for vi to treat all input the same, whether it comes
directly from the keyboard, or from a copy/paste buffer.

It did everything fine from '92 when I started using it on AIX until a
year or two back when I briefly went to Ubuntu 18.04 LTS. Then, I could
paste a command into it, and it would insert it into the text, rather
than executing it. Or, I'd paste (in input mode; repeatedly verified)
some TeX and it would decide that it was really a command and execute
it.

And I've just realized which group this is, so my complaint is
completely off-topic. Sorry.

--
Michael F. Stemper
Deuteronomy 24:17
--
https://mail.python.org/mailman/listinfo/python-list


Re: Function returns old value

2020-12-18 Thread Christian Gollwitzer

Am 17.12.20 um 21:22 schrieb Michael F. Stemper:

On 17/12/2020 03.57, Peter J. Holzer wrote:

On 2020-12-17 03:06:32 -, Bischoop wrote:

pasting from my IDE to vim/slrn was messing syntax,


You can

:set paste

in vim to prevent it from messing with pasted content (don't forget to
set nopaste afterwards).


What's the difference between that and
:set ai
and
:set noai


With newer vims that's rarely necessary though since they can distinguish
between input that was pasted and input that was typed.


I thought that I was going nuts when I encountered that. Any idea how to
defeat such a so-called 'feature"?


Use "gvim" instead of "vim" in a Terminal. The problems arises because 
vim in the terminal simply gets the input and "thinks" that you typed 
that stuff in, for which it does auto-indenting. gvim, OTOH, doe sthe 
pasting by itself. It also has other useful features like menus and 
popup-dialogs for searching etc.


Christian

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


Re: Function returns old value

2020-12-17 Thread Cameron Simpson
On 17Dec2020 14:22, Michael F. Stemper  wrote:
>On 17/12/2020 03.57, Peter J. Holzer wrote:
>>On 2020-12-17 03:06:32 -, Bischoop wrote:
>>>pasting from my IDE to vim/slrn was messing syntax,
>>
>>You can
>>
>>:set paste
>>
>>in vim to prevent it from messing with pasted content (don't forget to
>>set nopaste afterwards).
>
>What's the difference between that and
>:set ai
>and
>:set noai

Well, based on my experience (since the above is what I always do) that 
leave my automatic line folding and related "line wrapping" stuff still 
in play. Which I routinely have to repair if the pasted code is at all 
wide.

[ Experiments with ":set paste". ]

Yeah, the paste mode turns all that wrapping stuff off, and ":set 
nopaste" restores it intact. Ok, I guess I'm going to have to retrain my 
fingers now.

>>With newer vims that's rarely necessary though since they can 
>>distinguish
>>between input that was pasted and input that was typed.

Mine doesn't seem to (vim inside a MacOS iTerm).

>I thought that I was going nuts when I encountered that. Any idea how to
>defeat such a so-called 'feature"?

You mean having vim figure that out? I dunno. I came here from vi and 
haven't fully embraced al the stuff vim has.

I _did_ discover recently that somehow iTerm and/or vim knows about my 
vim split buffers and doesn't cross the entirely in-vim-curses window 
boundary, very very handy. I guess iTerm may know about terminal 
scrolling regions, if that's how vim implements the windowing stuff.

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


Re: Function returns old value

2020-12-17 Thread Michael F. Stemper

On 17/12/2020 03.57, Peter J. Holzer wrote:

On 2020-12-17 03:06:32 -, Bischoop wrote:

pasting from my IDE to vim/slrn was messing syntax,


You can

:set paste

in vim to prevent it from messing with pasted content (don't forget to
set nopaste afterwards).


What's the difference between that and
:set ai
and
:set noai


With newer vims that's rarely necessary though since they can distinguish
between input that was pasted and input that was typed.


I thought that I was going nuts when I encountered that. Any idea how to
defeat such a so-called 'feature"?


--
Michael F. Stemper
The name of the story is "A Sound of Thunder".
It was written by Ray Bradbury. You're welcome.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Function returns old value

2020-12-17 Thread Bischoop
On 2020-12-17, Peter J. Holzer  wrote:
>
> --EVF5PPMfhYS0aIcm
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> Content-Transfer-Encoding: quoted-printable
>
> On 2020-12-17 03:06:32 -, Bischoop wrote:
>> pasting from my IDE to vim/slrn was messing syntax,
>
> You can=20
>
>:set paste

Indeed, thanks I just didn't come to conclusion that it has to be special
paste mode to paste without breaking the lines. 
Also  adding in * set pastetoggle= * in vimrc activates paste
mode when pressing F2, I find it more convenient.
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Function returns old value

2020-12-17 Thread Bischoop
On 2020-12-17, dn  wrote:
>> After expiry, any posts 'here' with links to 'there', will be useless.
>> 
>> I do mind that however I thoght it better if paste a whole code to see
>> and pasting from my IDE to vim/slrn was messing syntax, I'll do better
>> next time.
>
>
> Yes, it can be difficult to know how much code to include and how much 
> can be left-out. Don't worry about that - replies can always trim any 
> excess.
>

I solved the pasting problem but about triming the excess, well
some people don't give a fuck and don't cut unecessary lines.
I'm pretty sure that if I post a 100 line code, some will reply without
cutting it just to point what's wrong in line 50 lol.




> Also, don't be concerned about such comments. Rather than complaints, 
> please regard them as advice from folk who have been 'here' and/or using 
> Python for some time.

I'm not concerned at all :-) 
I'm using newsgroups,irc for good over 20 years so I don't bother.

--
Thanks

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


Re: Function returns old value

2020-12-17 Thread Peter J. Holzer
On 2020-12-17 03:06:32 -, Bischoop wrote:
> pasting from my IDE to vim/slrn was messing syntax,

You can 

:set paste

in vim to prevent it from messing with pasted content (don't forget to
set nopaste afterwards).

With newer vims that's rarely necessary though since they can distinguish
between input that was pasted and input that was typed.

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: Function returns old value

2020-12-16 Thread dn via Python-list

On 17/12/2020 16:06, Bischoop wrote:

On 2020-12-17, dn  wrote:


Remember that posts to the list are archived, and thus may be searched.
People experiencing similar problems in-future will be able to 'mine'
the archives for help and advice.

Using a/any pastebin is great for immediate sharing. Remember that in
this case their links expire/the bin 'disappears'.

After expiry, any posts 'here' with links to 'there', will be useless.


I do mind that however I thoght it better if paste a whole code to see
and pasting from my IDE to vim/slrn was messing syntax, I'll do better
next time.



Yes, it can be difficult to know how much code to include and how much 
can be left-out. Don't worry about that - replies can always trim any 
excess.


Also, don't be concerned about such comments. Rather than complaints, 
please regard them as advice from folk who have been 'here' and/or using 
Python for some time.

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


Re: Function returns old value

2020-12-16 Thread Bischoop
On 2020-12-17, dn  wrote:

> Remember that posts to the list are archived, and thus may be searched. 
> People experiencing similar problems in-future will be able to 'mine' 
> the archives for help and advice.
>
> Using a/any pastebin is great for immediate sharing. Remember that in 
> this case their links expire/the bin 'disappears'.
>
> After expiry, any posts 'here' with links to 'there', will be useless.

I do mind that however I thoght it better if paste a whole code to see
and pasting from my IDE to vim/slrn was messing syntax, I'll do better
next time.

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


Re: Function returns old value

2020-12-16 Thread dn via Python-list

On 17/12/2020 15:40, Bischoop wrote:

On 2020-12-12, Terry Reedy  wrote:


Don't post links to unknown sites.  Reduce it to the minimum needed to
exhibit the questionable behavior and include inline with the question.



BTW bpa.st/+python is well known for code sharing among Python
communities it's alternative to pastebin.com.



Remember that posts to the list are archived, and thus may be searched. 
People experiencing similar problems in-future will be able to 'mine' 
the archives for help and advice.


Using a/any pastebin is great for immediate sharing. Remember that in 
this case their links expire/the bin 'disappears'.


After expiry, any posts 'here' with links to 'there', will be useless.
--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Function returns old value

2020-12-16 Thread Bischoop
On 2020-12-12, Terry Reedy  wrote:
>
> Don't post links to unknown sites.  Reduce it to the minimum needed to 
> exhibit the questionable behavior and include inline with the question.
>
>> How this functions should look properly?
>
>

I've solved the problem.
BTW bpa.st/+python is well known for code sharing among Python
communities it's alternative to pastebin.com.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Function returns old value

2020-12-12 Thread Joe Pfeiffer
Bischoop  writes:

> On 2020-12-12, Joe Pfeiffer  wrote:
>> Bischoop  writes:
>>
>>> I've function asking question and comparing it, if is not matching 'yes'
>>> it does call itself to ask question again. The problem is that when
>>> function is called second time it returns old value or with additional
>>> else statement it returns none.
>>>
>>> Code: https://bpa.st/KVGA
>>
>> It calls itself again, but what does it return in that case?
>
> I've stated it returns old value that I've input first time, anyway
> output is also inluded in a paste but since you've asked:

Sorry, my question wasn't clear.  What I meant was, "in your return
statement, what are you returning"?

You need to be returning the value from the recursive call.

> def question():
> ask = input("Are you OK?:").lower()
> if ask != 'yes':
>   question()
>   return ask
>
>   print (question())
>
>   #output:
>   Are you OK?:no
>   Are you OK?:no
>   Are you OK?:yes
>   no
>
>   ---
>   #Another way with 'elif' statment returns none
>
>
>   def question():
>   ask = input("Are you OK?:").lower()
>   if ask != 'yes':
>   question()
>   elif ask == 'yes':
>   return ask
>
>   print (question())
>
>   #output:
>   Are you OK?:no
>   Are you OK?:yes
>   None
>
>   #Tried also nested
>   functions, same results:
>
>   def question():
>   ask = input("Are you
>   OK?:").lower()
>
>   def
>   check_question(n):
>   if ask
>   !=
>   'yes':
>   
> question()
>   
> else:
>   
> return
>   
> ask
>
>   
> m
>   
> =
>   
> check_question(ask)
>   
> print
>   
> (m)
>   
> question()
>
>   
> #output:
>   
> Are
>   
> you
>   
> OK?:no
>   
> Are
>   
> you
>   
> OK?:yes
>   
> None
>
>   
> Process
>   
> finished
>   
> with
>   
> exit
> 

Re: Function returns old value

2020-12-11 Thread Terry Reedy

On 12/11/2020 8:25 PM, Bischoop wrote:


I've function asking question and comparing it, if is not matching 'yes'
it does call itself to ask question again. The problem is that when
function is called second time it returns old value or with additional
else statement it returns none.

Code: https://bpa.st/??


Don't post links to unknown sites.  Reduce it to the minimum needed to 
exhibit the questionable behavior and include inline with the question.



How this functions should look properly?



--
Terry Jan Reedy

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


Re: Function returns old value

2020-12-11 Thread Chris Angelico
On Sat, Dec 12, 2020 at 1:39 PM dn via Python-list
 wrote:
>
> On 12/12/2020 15:25, Chris Angelico wrote:
> > On Sat, Dec 12, 2020 at 1:23 PM dn via Python-list
> >  wrote:
> >>
> >> Speaking personally, I prefer the code to be included in the email.
> >> However, it would be better to use spaces rather than tabs (Python's
> >> preferred style, per PEP-8) because many email packages implement
> >> tab-stops as eight-spaces apart.
> >>
> >
> > Be careful of wording here. PEP 8 does not specify that all Python
> > code should use spaces rather than tabs. Tabs are absolutely fine for
> > your code.
>
> Hence "preferred", cf "prescribed" or "required".

It's not even that. It's required for the standard library, and not at
all a language recommendation elsewhere.

> My personal reaction when ppl do make such a demand, is to use the
> facility built-in to decent editors/IDEs to change from one to the other
> - no fuss, no muss; peace reigns amongst the team once again...!
>
> Wish could do that with such ease in other applications!

Ah yes, and then you have these massive source control diffs when you
do a meaningless conversion over large slabs of the code! Perfect,
just what we wanted.

For teams that disagree on the correct width of indentation levels,
why not standardize on a single token meaning "indentation level", and
then allow everyone to configure their editors to show it at whatever
width they prefer?

> Nevertheless, email-client observation applies...

Yes. Make sure you use an email client that supports leading
whitespace of all forms. Otherwise you're not going to have a good
time of it.

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


Re: Function returns old value

2020-12-11 Thread dn via Python-list

On 12/12/2020 15:25, Chris Angelico wrote:

On Sat, Dec 12, 2020 at 1:23 PM dn via Python-list
 wrote:


Speaking personally, I prefer the code to be included in the email.
However, it would be better to use spaces rather than tabs (Python's
preferred style, per PEP-8) because many email packages implement
tab-stops as eight-spaces apart.



Be careful of wording here. PEP 8 does not specify that all Python
code should use spaces rather than tabs. Tabs are absolutely fine for
your code.


Hence "preferred", cf "prescribed" or "required".

My personal reaction when ppl do make such a demand, is to use the 
facility built-in to decent editors/IDEs to change from one to the other 
- no fuss, no muss; peace reigns amongst the team once again...!


Wish could do that with such ease in other applications!

Nevertheless, email-client observation applies...
--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: Function returns old value

2020-12-11 Thread Chris Angelico
On Sat, Dec 12, 2020 at 1:23 PM dn via Python-list
 wrote:
>
> Speaking personally, I prefer the code to be included in the email.
> However, it would be better to use spaces rather than tabs (Python's
> preferred style, per PEP-8) because many email packages implement
> tab-stops as eight-spaces apart.
>

Be careful of wording here. PEP 8 does not specify that all Python
code should use spaces rather than tabs. Tabs are absolutely fine for
your code.

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


Re: Function returns old value

2020-12-11 Thread dn via Python-list

On 12/12/2020 15:09, Bischoop wrote:

On 2020-12-12, dn  wrote:

On 12/12/2020 14:25, Bischoop wrote:




I've function asking question and comparing it, if is not matching 'yes'
it does call itself to ask question again. The problem is that when
function is called second time it returns old value or with additional
else statement it returns none.

Code: https://bpa.st/KVGA

How this functions should look properly?



In the event of "yes" the function returns a value (return ask).
When the function calls itself, what happens to the return-ed value?


Apologies, the question was for you to ask yourself; not me asking for me!

When you read the code, to where are the results of the 'inner call' 
assigned?


If you can answer this question, you will solve 'the problem'!
(and have learned an approach to solving problems in-future)



Well I've put the output in a paste as well, anyway here is what is in a
paste:


Thank you.

Speaking personally, I prefer the code to be included in the email. 
However, it would be better to use spaces rather than tabs (Python's 
preferred style, per PEP-8) because many email packages implement 
tab-stops as eight-spaces apart.


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


Re: Function returns old value

2020-12-11 Thread Bischoop
On 2020-12-12, Joe Pfeiffer  wrote:
> Bischoop  writes:
>
>> I've function asking question and comparing it, if is not matching 'yes'
>> it does call itself to ask question again. The problem is that when
>> function is called second time it returns old value or with additional
>> else statement it returns none.
>>
>> Code: https://bpa.st/KVGA
>
> It calls itself again, but what does it return in that case?

I've stated it returns old value that I've input first time, anyway
output is also inluded in a paste but since you've asked:

def question():
ask = input("Are you OK?:").lower()
if ask != 'yes':
question()
return ask

print (question())

#output:
Are you OK?:no
Are you OK?:no
Are you OK?:yes
no

---
#Another way with 'elif' statment returns none


def question():
ask = input("Are you OK?:").lower()
if ask != 'yes':
question()
elif ask == 'yes':
return ask

print (question())

#output:
Are you OK?:no
Are you OK?:yes
None

#Tried also nested
functions, same results:

def question():
ask = input("Are you
OK?:").lower()

def
check_question(n):
if ask
!=
'yes':

question()

else:

return

ask


m

=

check_question(ask)

print

(m)

question()


#output:

Are

you

OK?:no

Are

you

OK?:yes

None


Process

finished

with

exit

code

0

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


Re: Function returns old value

2020-12-11 Thread Paul Bryan
Sorry, actually, if you do not answer yes, will always return None, not
the first answer as I suggested.

On Fri, 2020-12-11 at 18:55 -0700, Joe Pfeiffer wrote:
> Bischoop  writes:
> 
> > I've function asking question and comparing it, if is not matching
> > 'yes'
> > it does call itself to ask question again. The problem is that when
> > function is called second time it returns old value or with
> > additional
> > else statement it returns none.
> > 
> > Code: https://bpa.st/KVGA
> 
> It calls itself again, but what does it return in that case?

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


Re: Function returns old value

2020-12-11 Thread Bischoop
On 2020-12-12, dn  wrote:
> On 12/12/2020 14:25, Bischoop wrote:
>> 
>> 
>> 
>> I've function asking question and comparing it, if is not matching 'yes'
>> it does call itself to ask question again. The problem is that when
>> function is called second time it returns old value or with additional
>> else statement it returns none.
>> 
>> Code: https://bpa.st/KVGA
>> 
>> How this functions should look properly?
>
>
> In the event of "yes" the function returns a value (return ask).
> When the function calls itself, what happens to the return-ed value?


Well I've put the output in a paste as well, anyway here is what is in a
paste:

def question():
ask = input("Are you OK?:").lower()
if ask != 'yes':
question()
return ask

print (question())

#output:
Are you OK?:no
Are you OK?:no
Are you OK?:yes
no

---
#Another way with 'elif' statment returns none


def question():
ask = input("Are you OK?:").lower()
if ask != 'yes':
question()
elif ask == 'yes':
return ask

print (question())

#output:
Are you OK?:no
Are you OK?:yes
None

#Tried also nested
functions, same results:

def question():
ask = input("Are you
OK?:").lower()

def
check_question(n):
if ask
!=
'yes':

question()

else:

return

ask


m

=

check_question(ask)

print

(m)

question()


#output:

Are

you

OK?:no

Are

you

OK?:yes

None


Process

finished

with

exit

code


Re: Function returns old value

2020-12-11 Thread Paul Bryan
It won't return until the inner call to question (and it's not using
the return value on inner call). Eventually, (and not until you answer
yes) it will return the first answer.

On Fri, 2020-12-11 at 18:55 -0700, Joe Pfeiffer wrote:
> Bischoop  writes:
> 
> > I've function asking question and comparing it, if is not matching
> > 'yes'
> > it does call itself to ask question again. The problem is that when
> > function is called second time it returns old value or with
> > additional
> > else statement it returns none.
> > 
> > Code: https://bpa.st/KVGA
> 
> It calls itself again, but what does it return in that case?

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


Re: Function returns old value

2020-12-11 Thread Joe Pfeiffer
Bischoop  writes:

> I've function asking question and comparing it, if is not matching 'yes'
> it does call itself to ask question again. The problem is that when
> function is called second time it returns old value or with additional
> else statement it returns none.
>
> Code: https://bpa.st/KVGA

It calls itself again, but what does it return in that case?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Function returns old value

2020-12-11 Thread dn via Python-list

On 12/12/2020 14:25, Bischoop wrote:




I've function asking question and comparing it, if is not matching 'yes'
it does call itself to ask question again. The problem is that when
function is called second time it returns old value or with additional
else statement it returns none.

Code: https://bpa.st/KVGA

How this functions should look properly?



In the event of "yes" the function returns a value (return ask).
When the function calls itself, what happens to the return-ed value?
--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Function returns old value

2020-12-11 Thread Bischoop




I've function asking question and comparing it, if is not matching 'yes'
it does call itself to ask question again. The problem is that when
function is called second time it returns old value or with additional
else statement it returns none.

Code: https://bpa.st/KVGA

How this functions should look properly?

--
Thanks in advance


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