Re: Aw: Re: stuck on time

2019-12-08 Thread RobH

On 08/12/2019 22:06, Greg Ewing wrote:

On 9/12/19 7:47 am, RobH wrote:
I wanted it to work as is, like it did for the author, without 
changing anything.


So why should I now start to learn how python works.


There are many, many reasons a piece of code could work in one
environment but not another. Figuring out why requires actual
understanding, not just copy-pasting. Part of that involves
gaining at least a basic knowledge of the language you're using.

You can't expect folks here to do all your work for you. We're
trying to help, but we can't debug your code and/or system
remotely, because we don't know everything about it. We can
offer advice, but ultimately you're the one who has to work
it out.

If you don't think the project is worth that much effort,
that's up to you. But you asked for help, and we're doing our
best to give it.



Yes, fair comment that, and I do appreciate the people who do try to help.

Thank you to those.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Aw: Re: stuck on time

2019-12-08 Thread DL Neil via Python-list

It's a lot like the misuse of the word "theory".


You mean to say that in theory there is no difference between theory and 
practice, but in practice there is?


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


Re: Aw: Re: stuck on time

2019-12-08 Thread MRAB

On 2019-12-08 20:34, Michael Torrie wrote:

On 12/8/19 11:47 AM, RobH wrote:

Err, excuse me, I was not attempting to hack into someone else's code.
As the code is in the public domain, I wanted it to work as is, like it 
did for the author, without changing anything.


No worries, you're totally fine.  The word "hack" means something
different.  To hack means to work on, learn, modify, etc.  It's a
positive word in this context.  I was hacking on python code myself
yesterday.

The word for breaking into a system or program is/was "crack", like in 
"safe-cracking". In common parlance, however, people have picked up the 
word "hack" instead, which, as Michael says, means something else.


It's a lot like the misuse of the word "theory".

[snip]
--
https://mail.python.org/mailman/listinfo/python-list


Re: Aw: Re: stuck on time

2019-12-08 Thread Greg Ewing

On 9/12/19 7:47 am, RobH wrote:
I wanted it to work as is, like it 
did for the author, without changing anything.


So why should I now start to learn how python works.


There are many, many reasons a piece of code could work in one
environment but not another. Figuring out why requires actual
understanding, not just copy-pasting. Part of that involves
gaining at least a basic knowledge of the language you're using.

You can't expect folks here to do all your work for you. We're
trying to help, but we can't debug your code and/or system
remotely, because we don't know everything about it. We can
offer advice, but ultimately you're the one who has to work
it out.

If you don't think the project is worth that much effort,
that's up to you. But you asked for help, and we're doing our
best to give it.

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


Re: Aw: Re: stuck on time

2019-12-08 Thread Michael Torrie
On 12/8/19 11:47 AM, RobH wrote:
> Err, excuse me, I was not attempting to hack into someone else's code.
> As the code is in the public domain, I wanted it to work as is, like it 
> did for the author, without changing anything.

No worries, you're totally fine.  The word "hack" means something
different.  To hack means to work on, learn, modify, etc.  It's a
positive word in this context.  I was hacking on python code myself
yesterday.

> So why should I now start to learn how python works.

Well if you learn how Python works, then a lot of what you are trying to
do will become easier and make more sense.  For example, knowing how
Python works will tell you why your print_time() function returns
nothing (hint, the code you posted does not show a "return" statement,
hence the function will not return anything).

> If the code doesn't work for me after a fair trial, I'll move on to 
> something else.

I can sense that you are frustrated, and I can also sense frustration on
the part of those trying to assist you. I hope you will give it a fair
trial as the entire endeavor, and Python in particular, can be really
fun once you grasp it!

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


Re: Aw: Re: stuck on time

2019-12-08 Thread DL Neil via Python-list

On 9/12/19 7:47 AM, RobH wrote:

On 08/12/2019 16:49, Dennis Lee Bieber wrote:

On Sun, 8 Dec 2019 09:44:54 +, RobH  declaimed the
following:

def print_time():
  current_time = time.strftime("%I:%M")

...


I don't know if that is the correct way as I am just using the code from
the project I am trying to do


This is showing a severe lack of understanding in how Python itself
operates, leading me to recommend rereading a Python tutorial book before
attempting to hack into some one else's code.


+1
(in other words, agreement with others who have suggested that your 
knowledge of Python and/or programming, is insufficient to cope with the 
project you've set yourself)




Err, excuse me, I was not attempting to hack into someone else's code.
As the code is in the public domain, I wanted it to work as is, like it 
did for the author, without changing anything.


Please don't be upset. There are multiple understandings of the words 
"hack" and "hacker". Whereas most 'computer people' take the word "hack" 
to mean exactly what you are doing (and "crack" to refer to illegal 
access or ill-intent); the sad state of journalism (and Hollywood) has 
resulted in a confusion of the two.


Within the Python community, the word "hack" is used freely and without 
rancour, and includes both the permitted use of someone else's code, as 
you describe; and improving said code, as per @wlfraed's detailed 
analysis of the code-base's short-comings, a few hours ago.




So why should I now start to learn how python works.


Only you can answer this: is the effort required to bend the code to 
your will, worth the pleasure or utility the result will bring?


Alternatively, look at how much time *volunteers* have thought 
worth-while investing in helping you! (kudos @Karsten)



There is a safety issue here too. What if the original author had wicked 
intent, and the code actually performs to your disadvantage. How would 
you know? The only way is to inspect the code - reading it for example.



Following-on from the "hacking" comment, if the original author offered 
it to you/the world, and uploaded this code to some public repo(sitory), 
(s)he will also be happy for you/others to correct and improve.


Added to the observation that the code is missing parentheses, it would 
seem that (this version of) the code would never work. Now that you have 
discovered this, the conventions of "open source" are that you will 
propose, or better still, supply a fix...



If the code doesn't work for me after a fair trial, I'll move on to 
something else.


Frankly, given @wlfraed's extensive analysis of the code, I'd be 
wondering about its utility too - but again, your assessment is the only 
one that counts.


(If I am confusing two recent list-threads, I apologise)
If you are going to be experimenting with IoT and/or SBCs, the sad 
reality is that it is not an area which has had time to 'collect' a body 
of mature software. Accordingly, lots of the code made 'available' for 
use will be in a fairly rough (or "early") stage. Thus, the greater 
*your* skill-set, the more likely will be success - same as for any 
hobby/work-project! Also, IIRC you are also short-cutting by using a 
Pi-Zero (designed for application and roll-out) rather than a board 
designed for experimentation - but I'm guessing, so again, please don't 
take offense.

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


Re: Aw: Re: stuck on time

2019-12-08 Thread RobH

On 08/12/2019 16:49, Dennis Lee Bieber wrote:

On Sun, 8 Dec 2019 09:44:54 +, RobH  declaimed the
following:


def print_time():
  current_time = time.strftime("%I:%M")

returns nothing.


So what did you expect it to do?

All that does is define a function (binding the name "print_time" to a
compiled function object), and that function itself returns nothing IF
invoked (you haven't invoked it). (Presuming time has been imported, the
function will bind the name "current_time" to a string representation of
the current time... and then throws away "current_time" when the function
falls off the end and returns to the caller.)


I don't know if that is the correct way as I am just using the code from
the project I am trying to do


This is showing a severe lack of understanding in how Python itself
operates, leading me to recommend rereading a Python tutorial book before
attempting to hack into some one else's code.




Err, excuse me, I was not attempting to hack into someone else's code.
As the code is in the public domain, I wanted it to work as is, like it 
did for the author, without changing anything.


So why should I now start to learn how python works.

If the code doesn't work for me after a fair trial, I'll move on to 
something else.

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


Re: Aw: Re: stuck on time

2019-12-08 Thread RobH

On 08/12/2019 08:18, Karsten Hilbert wrote:

Sorry, I should have said just the line, and it didn't return anything.


OK, a bit strange, but then that might be due to Thonny.


Is Thonny an interpreter then.


It sort of is, or at least it runs one. We'd like to take
that out of the equation. I meant to run *just* an interpreter, namely,
the interactive shell built into Python itself.

IOW, run just "python" (or python3) on a command line and a shell
should open in which you can run the line in question.

(remember to define "time" appropriately)

Karsten



In an interactive interpreter:

def print_time():
  current_time = time.strftime("%I:%M")

returns nothing.

I don't know if that is the correct way as I am just using the code from 
the project I am trying to do

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


Re: Aw: Re: stuck on time

2019-12-08 Thread DL Neil via Python-list

On 8/12/19 9:18 PM, Karsten Hilbert wrote:

Sorry, I should have said just the line, and it didn't return anything.


OK, a bit strange, but then that might be due to Thonny.


Is Thonny an interpreter then.


It sort of is, or at least it runs one. We'd like to take
that out of the equation. I meant to run *just* an interpreter, namely,
the interactive shell built into Python itself.

IOW, run just "python" (or python3) on a command line and a shell
should open in which you can run the line in question.

(remember to define "time" appropriately)


From response just posted to Python-Tutor list:

WebRefs:
https://pythonprogramminglanguage.com/repl/
https://codewith.mu/en/tutorials/1.0/repl

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


Aw: Re: stuck on time

2019-12-08 Thread Karsten Hilbert
> Sorry, I should have said just the line, and it didn't return anything.

OK, a bit strange, but then that might be due to Thonny.

> Is Thonny an interpreter then.

It sort of is, or at least it runs one. We'd like to take
that out of the equation. I meant to run *just* an interpreter, namely,
the interactive shell built into Python itself.

IOW, run just "python" (or python3) on a command line and a shell
should open in which you can run the line in question.

(remember to define "time" appropriately)

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