Re: Need help please

2023-04-10 Thread Thomas Passin

On 4/10/2023 9:59 AM, Jack Gilbert wrote:

I D/L 3.11.3, I can see it in CMD

running W10 64bit

I have IDL on my desktop,

HOW do I get 3.11.3 on my desktop?


If you mean "How can I create a shortcut to Python 3.11.3 on my desktop 
that opens an interactive Python session", here is one way:


1. Find where your Python 3.11.3 program has been installed.  On the 
command line in a console, type:


py -c "import sys; print(sys.executable)"

You will get a response like this:

C:\Users\tom\AppData\Local\Programs\Python\Python311\python.exe

NOTE:  If the "py" command is not on your computer or does not open 
Python 3.11, then open a python 3.11 session and type the same commands:


import sys
print(sys.executable)

2. Open the Windows file browser ("Windows Explorer") and navigate to 
that directory.  On my computer this is


C:\Users\tom\AppData\Local\Programs\Python\Python311

3. Press and hold both the CTRL and SHIFT keys down at the same time, 
and with the mouse drag the icon for "python.exe" to a blank space on 
the desktop.  This will not drag the program itself but will create a 
shortcut and drag that.


4. Test the new shortcut by double-clicking on it and seeing that a new 
console window opens with the Python interpreter running in it.


If you do not like the size, shape, or font of this new console, change 
them by clicking on the icon in the upper left, then selecting 
"Properties", and making changes in the dialog box that opens.  The new 
choices will be used whenever you use this shortcut again.


5. The new shortcut will probably be named "python.ex".  I suggest that 
you rename it to "Python 3.11".  This way you can create other python 
shortcuts without having their names conflict.

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


Re: Need help please

2023-04-10 Thread Sravan Kumar Chitikesi
use where cmd to find out the path of the binary and create a shortcut to
that file on desktop

Regards,
*Sravan Chitikesi*
AWS Solutions Architect - Associate


On Mon, Apr 10, 2023 at 10:03 AM Jack Gilbert <00jhen...@gmail.com> wrote:

> I D/L 3.11.3, I can see it in CMD
>
> running W10 64bit
>
> I have IDL on my desktop,
>
> HOW do I get 3.11.3 on my desktop?
>
> Thanks
>
> Jack g
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Need help please

2023-04-10 Thread Jack Gilbert
I D/L 3.11.3, I can see it in CMD

running W10 64bit

I have IDL on my desktop,

HOW do I get 3.11.3 on my desktop?

Thanks

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


Re: help, please, with 3.10.4 install

2022-05-30 Thread Dennis Lee Bieber
On Sat, 28 May 2022 21:11:00 -0500, Jack Gilbert <00jhen...@gmail.com>
declaimed the following:

>also, the same line: Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022,
>23:13:41) [MSC v.1929 64 bit (AMD64)] on win32 in CMD prompt
>
>for the life of me I can't figure out how to launch python??
>

Well, what did you type in that command shell to get the line you
report above? (Cut and Paste the TEXT from that command shell -- don't just
transcribe by hand). That version string is only displayed when one starts
Python in interactive mode.

-=-=-
Microsoft Windows [Version 10.0.19044.1706]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Wulfraed>python
Python ActivePython 3.8.2 (ActiveState Software Inc.) based on
 on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

-=-=-



-- 
Wulfraed Dennis Lee Bieber AF6VN
wlfr...@ix.netcom.comhttp://wlfraed.microdiversity.freeddns.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: help, please, with 3.10.4 install

2022-05-30 Thread Mats Wichmann
On 5/28/22 20:11, Jack Gilbert wrote:
> I downloaded 3.10.4 on a 64 bit , 8.1

> also, the same line: Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022,
> 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32 in CMD prompt
> 
> for the life of me I can't figure out how to launch python??

Sounds like you're launching it already?

In a cmd shell, type:

py


And you should be good to go.  See the page @dn pointed to.


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


Re: help, please, with 3.10.4 install

2022-05-29 Thread dn
On 29/05/2022 14.11, Jack Gilbert wrote:
> I downloaded 3.10.4 on a 64 bit , 8.1
> I can see IDLE shell 3.10.1, I see Python 3.10.4 (tags/v3.10.4:9d38120, Mar
> 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32
> 
> also, the same line: Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022,
> 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32 in CMD prompt
> 
> for the life of me I can't figure out how to launch python??
> 
> I did click add to path in the install
> 
> thanks


Please advise if https://docs.python.org/3/using/windows.html does not
answer the question...
-- 
Regards,
=dn
-- 
https://mail.python.org/mailman/listinfo/python-list


help, please, with 3.10.4 install

2022-05-29 Thread Jack Gilbert
I downloaded 3.10.4 on a 64 bit , 8.1
I can see IDLE shell 3.10.1, I see Python 3.10.4 (tags/v3.10.4:9d38120, Mar
23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32

also, the same line: Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022,
23:13:41) [MSC v.1929 64 bit (AMD64)] on win32 in CMD prompt

for the life of me I can't figure out how to launch python??

I did click add to path in the install

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


Re: HELP Please, Python Program Help

2021-04-10 Thread dn via Python-list
On 10/04/2021 22.57, Joseph Roffey wrote:
> Hi, Im looking for some help with my program, I have been set a task to make 
> a Strain Calculator. I need it to input two numbers, choosing either Metres 
> or Inches for the 'Change in Length' divided by the 'Original Length' which 
> can also be in Metres or Inches, the out put number also needs to give an 
> option for the answer to be in metres or inches.
> 
> this is what i have come up with so far...

What is the problem?


> txt = "Strain Calculator"
> x = txt.title()

what is the above/


> print(x)
> 
> # This function divides two numbers
> def divide(x, y):
>   return x / y

Why use a function instead of operating in-line?

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


HELP Please, Python Program Help

2021-04-10 Thread Joseph Roffey
Hi, Im looking for some help with my program, I have been set a task to make a 
Strain Calculator. I need it to input two numbers, choosing either Metres or 
Inches for the 'Change in Length' divided by the 'Original Length' which can 
also be in Metres or Inches, the out put number also needs to give an option 
for the answer to be in metres or inches.

this is what i have come up with so far...


txt = "Strain Calculator"
x = txt.title()
print(x)

# This function divides two numbers
def divide(x, y):
return x / y

print("Select operation.")
print("1.Strain")

while True:
# Take input from the user
choice = input("Enter choice(1): ")

# Check if choice is one of the five options
if choice in ('1'):
num1 = float(input("Change in Length: "))
num2 = float(input("Original Length: "))

if choice == '1':
 print(num1, "/", num2, "=", divide(num1, num2)) 
break
else:
print("Invalid Input")


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


Re: Help Please

2021-03-28 Thread D'Arcy Cain

On 2021-03-26 12:42 p.m., Igor Korot wrote:

On top of that - usual stanza applies:

1. OS - Windows, Linux, Mac?
2. OS version?
3. Python version?
4. Are you able to run python interpretor?
5. Socks version you are trying to install?
6. Was install successful?


7. Use a subject that describes the actual issue.

--
D'Arcy J.M. Cain
Vybe Networks Inc.
A unit of Excelsior Solutions Corporation - Propelling Business Forward
http://www.VybeNetworks.com/
IM:da...@vybenetworks.com VoIP: sip:da...@vybenetworks.com
--
https://mail.python.org/mailman/listinfo/python-list


Re: Help Please

2021-03-26 Thread Igor Korot
Hi,

On Fri, Mar 26, 2021 at 11:36 AM Anis4Games  wrote:

> Hello python support team , i need help about packages and python modules
>
> That Video Will Explain My Problem
>

Please don't send any attachment to the list - it will be dropped from the
E-mail.

Cut'n'paste any errors you receive directly in the body of the message.

On top of that - usual stanza applies:

1. OS - Windows, Linux, Mac?
2. OS version?
3. Python version?
4. Are you able to run python interpretor?
5. Socks version you are trying to install?
6. Was install successful?

Thank you.


> The Problem : Is Im Installed [Socks] Alredy With Command => pip install
> socks
>
> But When i run some script using socks pack its show a error with message "
> import socks " no socks modules found
>
> So Please Help Me😫
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Help Please

2021-03-26 Thread Anis4Games
Hello python support team , i need help about packages and python modules

That Video Will Explain My Problem

The Problem : Is Im Installed [Socks] Alredy With Command => pip install
socks

But When i run some script using socks pack its show a error with message "
import socks " no socks modules found

So Please Help Me😫
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help please installing Python on Windows 10

2018-10-04 Thread Sibylle Koczian

Am 03.10.2018 um 09:34 schrieb Timothy Cowell via Python-list:

Could I please ask for help installing Python on Windows 10 - I've tried twice 
(Version 3.7 for windows) selecting the install now option. After first attempt 
I uninstalled and tried again.

Each time it has put 4 items in the programs list from the windows start 
button, all under heading Python 3.7, but the first time they said 64 bit and 
the second time only 32 bit - I guess I must have clicked on different versions.

32 bit on a 64 bit PC and Windows version should work, 64 bit on 32 bit 
Windows probably not. So, if you kept your second attempt, that should 
be enough to start with.


Both times there was IDLE, Python 3.7, Manuals, and Module Docs. The last two 
of these worked when clicked on, but the first two just put up a small window 
of which first was white, and second was black, but I couldn't make them do 
anything.


IDLE and the Python shell both start with windows showing text like this:

Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 
bit (AMD64)] on win32

Type "copyright", "credits" or "license()" for more information.
>>>

Did you get something like this? In that case nothing was wrong, Python 
just waited for your commands. The manual contains a tutorial which 
starts using the interactive interpreter - try it out. If you don't get 
the results the tutorial predicts, come back here or subscribe to the 
tutor list:

Tutor maillist  -  tu...@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

If your "small windows" don't contain such a header, that really would 
look wrong. In that case: are they completely empty? Or what else? If 
they contain any text at all, can you copy and paste it into your 
answer? Please don't try to send a screenshot, the list won't accept it.


HTH
Sibylle





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


Help please installing Python on Windows 10

2018-10-03 Thread Timothy Cowell via Python-list


Hi,


Could I please ask for help installing Python on Windows 10 - I've tried twice 
(Version 3.7 for windows) selecting the install now option. After first attempt 
I uninstalled and tried again.


Each time it has put 4 items in the programs list from the windows start 
button, all under heading Python 3.7, but the first time they said 64 bit and 
the second time only 32 bit - I guess I must have clicked on different versions.


Both times there was IDLE, Python 3.7, Manuals, and Module Docs. The last two 
of these worked when clicked on, but the first two just put up a small window 
of which first was white, and second was black, but I couldn't make them do 
anything.



Could you please tell me what I'm doing wrong?


Many thanks, Tim.

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


Re: I am new here and i need your help please

2017-07-26 Thread yasirrbadamasi
Thank you for your responses, i really appreciate
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am new here and i need your help please

2017-07-25 Thread Rustom Mody
On Wednesday, July 26, 2017 at 12:11:27 PM UTC+5:30, dieter wrote:
> yasirrbadamasi:
> 
> > I have never execute any program before using python and a task was given 
> > to me by my teacher 
> 
> I suggest to start by reading the Python tutorial:
> "https://docs.python.org/3/tutorial/index.html";.

I was about to say that…

Some additions:
You will also need to have python installed on your computer.
Have you done that? Do you need help with that? Start here and if any issue
report with details including your OS (windows/linux/Mac):
https://www.python.org/downloads/

After that, for a beginner below list may be more helpful than this one 
[recommended]:
https://mail.python.org/mailman/listinfo/tutor
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am new here and i need your help please

2017-07-25 Thread dieter
yasirrbadam...@gmail.com writes:

> I have never execute any program before using python and a task was given to 
> me by my teacher 

I suggest to start by reading the Python tutorial:
"https://docs.python.org/3/tutorial/index.html";.

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


Re: I am new here and i need your help please

2017-07-25 Thread Wildman via Python-list
On Tue, 25 Jul 2017 00:48:25 -0700, yasirrbadamasi wrote:

> I have never execute any program before using python and a task was given to 
> me by my teacher 
> ~ to write a python program to print my details and store in a third party 
> variables.
> ~ the details include name, age, height, status. so please your help is 
> highly needed, thanks

Read the material and write some code the best you can
and post it here.  Someone will try to help you.  No
one here is going to do your homework for you.

-- 
 GNU/Linux user #557453
May the Source be with you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am new here and i need your help please

2017-07-25 Thread Steven D'Aprano
On Tue, 25 Jul 2017 00:48:25 -0700, yasirrbadamasi wrote:

> I have never execute any program before using python and a task was
> given to me by my teacher ~ to write a python program to print my
> details and store in a third party variables.
> ~ the details include name, age, height, status. so please your help is
> highly needed, thanks

What part of the assignment don't you understand?



-- 
“You are deluded if you think software engineers who can't write 
operating systems or applications without security holes, can write 
virtualization layers without security holes.” —Theo de Raadt
-- 
https://mail.python.org/mailman/listinfo/python-list


I am new here and i need your help please

2017-07-25 Thread yasirrbadamasi
I have never execute any program before using python and a task was given to me 
by my teacher 
~ to write a python program to print my details and store in a third party 
variables.
~ the details include name, age, height, status. so please your help is highly 
needed, thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Working with dictionaries and keys help please!

2017-06-02 Thread Gregory Ewing

On Thu, 1 Jun 2017 10:29 am, David D wrote:


Is there a way of performing this
where the key will update so that is continues to work sequentially?


It sounds like you don't want a dictionary at all, you want a list.
You can use the index() method to find the current "key" of an entry.

>>> people = ["John", "David", "Phil", "Bob"]
>>> people.index("Phil")
2
>>> people.remove("David")
>>> people.index("Phil")
1

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


Re: Working with dictionaries and keys help please!

2017-06-01 Thread Steve D'Aprano
On Thu, 1 Jun 2017 10:29 am, David D wrote:

> I have a dictionary with a 10 people, the key being a number (0-10) and the
> value being the people's name.  I am in the processing of Insert, Adding and
> deleting from the dictionary.  All seems well until I delete a person and add
> a new one.  The numbers (keys) do not change and so I am getting an
> non-sequential set of numbers for the keys.  Is there a way of performing this
> where the key will update so that is continues to work sequentially?  Here is
> what I mean
> 
> Print dictionary
> {0 John, 1 David, 2 Phil, 3 Bob}
> 
> remove 1 David
> {0 John, 2 Phil, 3 Bob}
> 
> How can I get it so that the VALUE will reset and it will look like this after
> both adding or deleting?
> 
> {0 John, 1 Phil, 2 Bob}


You can't. That's not how dicts work.

The dictionary key is similar to the primary key in a database. The fact that
they start off as sequential values is irrelevant. Imagine that you create an
account for Phil, and he gets account number 2; then Bob gets account number 3:

print(accounts)
=> {0: John, 1: David, 2: Phil, 3: Bob}

Then you delete David's account. Then Phil calls you, tells you his account
number is 2, and you access Bob's records instead of Phil's!

Database keys should never be changed or reused.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: Working with dictionaries and keys help please!

2017-05-31 Thread David D
Learning about dictionaries for a database possibly in the future.

On Wednesday, May 31, 2017 at 8:58:39 PM UTC-4, MRAB wrote:
> On 2017-06-01 01:29, David D wrote:
> > I have a dictionary with a 10 people, the key being a number (0-10) and the 
> > value being the people's name.  I am in the processing of Insert, Adding 
> > and deleting from the dictionary.  All seems well until I delete a person 
> > and add a new one.  The numbers (keys) do not change and so I am getting an 
> > non-sequential set of numbers for the keys.  Is there a way of performing 
> > this where the key will update so that is continues to work sequentially?  
> > Here is what I mean
> > 
> > Print dictionary
> > {0 John, 1 David, 2 Phil, 3 Bob}
> > 
> > remove 1 David
> > {0 John, 2 Phil, 3 Bob}
> > 
> > How can I get it so that the VALUE will reset and it will look like this 
> > after both adding or deleting?
> > 
> > {0 John, 1 Phil, 2 Bob}
> > 
> Why are you using a dictionary instead of a list?

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


Re: Working with dictionaries and keys help please!

2017-05-31 Thread MRAB

On 2017-06-01 01:29, David D wrote:

I have a dictionary with a 10 people, the key being a number (0-10) and the 
value being the people's name.  I am in the processing of Insert, Adding and 
deleting from the dictionary.  All seems well until I delete a person and add a 
new one.  The numbers (keys) do not change and so I am getting an 
non-sequential set of numbers for the keys.  Is there a way of performing this 
where the key will update so that is continues to work sequentially?  Here is 
what I mean

Print dictionary
{0 John, 1 David, 2 Phil, 3 Bob}

remove 1 David
{0 John, 2 Phil, 3 Bob}

How can I get it so that the VALUE will reset and it will look like this after 
both adding or deleting?

{0 John, 1 Phil, 2 Bob}


Why are you using a dictionary instead of a list?
--
https://mail.python.org/mailman/listinfo/python-list


Working with dictionaries and keys help please!

2017-05-31 Thread David D
I have a dictionary with a 10 people, the key being a number (0-10) and the 
value being the people's name.  I am in the processing of Insert, Adding and 
deleting from the dictionary.  All seems well until I delete a person and add a 
new one.  The numbers (keys) do not change and so I am getting an 
non-sequential set of numbers for the keys.  Is there a way of performing this 
where the key will update so that is continues to work sequentially?  Here is 
what I mean

Print dictionary
{0 John, 1 David, 2 Phil, 3 Bob}

remove 1 David
{0 John, 2 Phil, 3 Bob}

How can I get it so that the VALUE will reset and it will look like this after 
both adding or deleting?

{0 John, 1 Phil, 2 Bob}

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


Re: Help Please ! Undocumented ERROR message so dont know how to fix the problem

2017-05-03 Thread Stephen Tucker
To murdock: What Rhodri wrote is correct. I sense that it might be helpful
for you if I were to tell you that there is a difference between a function
and a function call. If your function were named

MyFunction

then

print (MyFunction)

would print a user-friendly-ish message about the function. This message
tells you (a) that the object you are asking Python to print is a function,
and (b) the address (in hexadecimal) in memory where the code for
MyFunction is stored. This is what your code is doing - hence the message
from Python.

If, on the other hand you have

print (MyFunction(any-parameters-to-MyFunction-with-commas-between-them))

then Python would recognise that (a) you are wanting it to call MyFunction
with the specified parameters, if any, (b) you are expecting that the
function will return a printable result, and (c) you are also expecting it
to print that result.

So, in order to get Python to do that, all you need to do is:

(1) to add the parentheses after the function name in the print statement [
so print (MyFunction) becomes print (MyFunction()) ];

(2) If your function has any parameters, add them, separated with commas,
between the parentheses [ so print (MyFunction()) becomes print
(MyFunction(parameters-separated-with-commas)) ];

(3) and rerun the new code - which should then do what you are wanting it
to do.

I hope this helps.

Stephen Tucker.










Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Tue, May 2, 2017 at 2:11 PM, Rhodri James  wrote:

> On 02/05/17 03:57, murdock wrote:
>
>> I am having a problem that seems to persist. I have written a program
>> that makes a mathematical calculation and uses a uses library that I have
>> written. It had been working but somehow in playing around with it, it
>> stoppedgo figure!  But here is the thing, when I run the program it
>> gives me a very ambiguous message with only a string as in:
>>
>> "The Receiver Noise Figure =  > 0x063E5A60>  dBm"
>>
>
> This is not an error message.  This is Python faithfully printing out what
> you asked it to print out.  Here's the line that does the printing:
>
> print ("The Receiver Noise Figure = ",Hamath._Noise_Figure," dBm" )
>
> The weird-looking bit of the message is the representation of a function,
> and lo! in the parameters to print() there is the function
> Hamath._Noise_Figure.  Note that this is the function itself, *not* the
> result of calling it, since you *don't* call it.
>
> --
> Rhodri James *-* Kynesim Ltd
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help Please ! Undocumented ERROR message so dont know how to fix the problem

2017-05-02 Thread Rhodri James

On 02/05/17 03:57, murdock wrote:

I am having a problem that seems to persist. I have written a program that 
makes a mathematical calculation and uses a uses library that I have written. 
It had been working but somehow in playing around with it, it stoppedgo 
figure!  But here is the thing, when I run the program it gives me a very 
ambiguous message with only a string as in:

"The Receiver Noise Figure =
dBm"


This is not an error message.  This is Python faithfully printing out 
what you asked it to print out.  Here's the line that does the printing:


print ("The Receiver Noise Figure = ",Hamath._Noise_Figure," dBm" )

The weird-looking bit of the message is the representation of a 
function, and lo! in the parameters to print() there is the function 
Hamath._Noise_Figure.  Note that this is the function itself, *not* the 
result of calling it, since you *don't* call it.


--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Re: Help Please ! Undocumented ERROR message so dont know how to fix the problem

2017-05-02 Thread Steve D'Aprano
On Tue, 2 May 2017 12:57 pm, murdock wrote:

> I am having a problem that seems to persist. I have written a program that
> makes a mathematical calculation and uses a uses library that I have
> written. It had been working but somehow in playing around with it, it
> stoppedgo figure!  But here is the thing, when I run the program it
> gives me a very ambiguous message with only a string as in:
> 
> "The Receiver Noise Figure =   0x063E5A60>  dBm"

That is absolutely not a Python error message.

There are two sorts of Python error messages: tracebacks, and segmentation
faults. You should never see  segmentation fault (if you do, it is a bug or
corruption in the Python interpreter) but if you do, there may not even be
message aside from "Segmentation fault". So forget all about them.

The only sort of Python error message you are likely to see is a traceback,
which looks like this:

Traceback (most recent call last):
  File "", line 1, in 
ValueError: not enough values to unpack (expected 2, got 1)


There may be more lines between the "Traceback" line and the last line,
which will be the actual error. It may not be ValueError, it could be
TypeError, AttributeError, IndexError, or many other things.

> now the program is being run under PyScripter

What happens if you *don't* run the program under PyScripter?

It looks to me that PyScripter is trying to be "helpful" by hiding the
actual error message from you, and perhaps showing you some random
diagnostic, or the line of code that failed.

Of course that's not helpful at all. See if you can run the script without
involving PyScripter. The easiest way is to enter the following at a
terminal or console:

python myscript.py

Replace the "myscript.py" with the actual name of your Python .py file.



> I am told that the error message is NOT an PyScripter error but in fact a
> Python message. 

Who told you this? I'm pretty sure they're wrong.

Unless they are going by more information than you've told us.


-- 
Steve
Emoji: a small, fuzzy, indistinct picture used to replace a clear and
perfectly comprehensible word.

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


Re: Help Please ! Undocumented ERROR message so dont know how to fix the problem

2017-05-01 Thread Gregory Ewing

murdock wrote:

BW = float (input ("Enter the Receiver Bandwidth in Hz"))
Signal_to_Noise = float (input ("Enter the Signal to Noise in dB"))
RX_Sensitivity = float (input ("Enter the RX_Sensitivity in dBm"))
#
print ("The Receiver Noise Figure = ",Hamath._Noise_Figure," dBm" )


I'm guessing you intend the three values you calculate to be
passed as parameters to the function:

   print("The Receiver Noise Figure = ", Hamath._Noise_Figure(BW, 
Signal_to_Noise, RX_Sensitivity), " dBm")


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


Re: Help Please ! Undocumented ERROR message so dont know how to fix the problem

2017-05-01 Thread Michael Torrie
On 05/01/2017 08:57 PM, murdock wrote:
> I am having a problem that seems to persist. I have written a program that 
> makes a mathematical calculation and uses a uses library that I have written. 
> It had been working but somehow in playing around with it, it stoppedgo 
> figure!  But here is the thing, when I run the program it gives me a very 
> ambiguous message with only a string as in:
> 
> "The Receiver Noise Figure =
> dBm"  

> import Hamath
> import math
>
> def main():
> #import math
>
> BW = float (input ("Enter the Receiver Bandwidth in Hz"))
> Signal_to_Noise = float (input ("Enter the Signal to Noise in dB"))
> RX_Sensitivity = float (input ("Enter the RX_Sensitivity in dBm"))
> #
> print ("The Receiver Noise Figure = ",Hamath._Noise_Figure," dBm" )
> if __name__ == '__main__':
> main()

Hamaht._Noise_Figure is a function.  In fact you said so yourself.  But
you're not calling it, nor is your code doing anything with the RW and
Signal_to_Noise variables.

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


Help Please ! Undocumented ERROR message so dont know how to fix the problem

2017-05-01 Thread murdock
I am having a problem that seems to persist. I have written a program that 
makes a mathematical calculation and uses a uses library that I have written. 
It had been working but somehow in playing around with it, it stoppedgo 
figure!  But here is the thing, when I run the program it gives me a very 
ambiguous message with only a string as in:

"The Receiver Noise Figure =
dBm"  

now the program is being run under PyScripter 

Function is called "Hamath" and has many functions in it but the one in 
question is:


def _Noise_Figure(BW,Signal_to_Noise,RX_Sensitivity):
''' calculates the noise figure of a receiver '''
#import math

return (174 + RX_Sensitivity - (10*log10(BW)) - Signal_to_Noise)

#

and the program that exercises that function is:

import Hamath
import math

def main():
#import math

BW = float (input ("Enter the Receiver Bandwidth in Hz"))
Signal_to_Noise = float (input ("Enter the Signal to Noise in dB"))
RX_Sensitivity = float (input ("Enter the RX_Sensitivity in dBm"))
#
print ("The Receiver Noise Figure = ",Hamath._Noise_Figure," dBm" )
if __name__ == '__main__':
main()

I am told that the error message is NOT an PyScripter error but in fact a 
Python message. But I can not find it anywhere in any of the documentation 
hence I have not been able to fix my problem.  

Any help would be appreciated.

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


Re: trying to make a simple program help please :)

2016-10-14 Thread BartC

On 14/10/2016 19:53, LongHairLuke wrote:

Den fredag 14 oktober 2016 kl. 20:30:20 UTC+2 skrev MRAB:

On 2016-10-14 19:11, LongHairLuke wrote:

Hi, l l am trying to make a simple guess program. This is my script:

def main():
print ("Guess a letter between a and e")
randomNumber = b

userGuess = input("Your guess: ")

if userGuess == randomNumber:
 print("You got it")
else:
 print ("That's not it")

main()


When l run the program l get error: userGuess is not defined, but l defined 
userGuess at line 5. I don't get it someone plese help :)


Lines 7 to 10 should be indented like the preceding lines. The way
you've written them, they're outside 'main'.


indented? can you explain :)



def main():
print ("Guess a letter between a and e")
randomNumber = b

userGuess = input("Your guess: ")

if userGuess == randomNumber:
print("You got it")
else:
print ("That's not it")

main()

(Python doesn't have explicit block-end delimiters. The end of a block 
(of the one compromising the body of function main in this case) has to 
be inferred from encountering some statement at the same or lower indent 
level than the opening 'def'. Or the end of the file.)


Anyway, the above won't completely fix the program as you haven't 
defined b, although you may have intended "b", even though you've called 
the variable 'randomNUMBER'.


With "b" in place of b, the program works on Python 3, although it 
doesn't verify bad inputs.


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


Re: trying to make a simple program help please :)

2016-10-14 Thread Irmen de Jong
Right, another troll.

plonk


Irmen

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


Re: trying to make a simple program help please :)

2016-10-14 Thread LongHairLuke
Den fredag 14 oktober 2016 kl. 20:30:20 UTC+2 skrev MRAB:
> On 2016-10-14 19:11, LongHairLuke wrote:
> > Hi, l l am trying to make a simple guess program. This is my script:
> >
> > def main():
> > print ("Guess a letter between a and e")
> > randomNumber = b
> >
> > userGuess = input("Your guess: ")
> >
> > if userGuess == randomNumber:
> >  print("You got it")
> > else:
> >  print ("That's not it")
> >
> > main()
> >
> >
> > When l run the program l get error: userGuess is not defined, but l defined 
> > userGuess at line 5. I don't get it someone plese help :)
> >
> Lines 7 to 10 should be indented like the preceding lines. The way 
> you've written them, they're outside 'main'.

indented? can you explain :) 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: trying to make a simple program help please :)

2016-10-14 Thread Irmen de Jong
On 14-10-2016 20:11, LongHairLuke wrote:
> Hi, l l am trying to make a simple guess program. This is my script: 
> 
> def main():
> print ("Guess a letter between a and e")
> randomNumber = b
> 
> userGuess = input("Your guess: ")
> 
> if userGuess == randomNumber:
>  print("You got it")
> else:
>  print ("That's not it")
> 
> main()
> 
> 
> When l run the program l get error: userGuess is not defined, but l defined 
> userGuess at line 5. I don't get it someone plese help :) 
> 
> Lukas Alberts 
> 

The indentation of the if/else statement in your program is off.  Fix it by 
properly
indenting the if-else to be at the same indentation level as the other lines 
that should
be part of the main() function.


Irmen

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


Re: trying to make a simple program help please :)

2016-10-14 Thread MRAB

On 2016-10-14 19:11, LongHairLuke wrote:

Hi, l l am trying to make a simple guess program. This is my script:

def main():
print ("Guess a letter between a and e")
randomNumber = b

userGuess = input("Your guess: ")

if userGuess == randomNumber:
 print("You got it")
else:
 print ("That's not it")

main()


When l run the program l get error: userGuess is not defined, but l defined 
userGuess at line 5. I don't get it someone plese help :)

Lines 7 to 10 should be indented like the preceding lines. The way 
you've written them, they're outside 'main'.


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


trying to make a simple program help please :)

2016-10-14 Thread LongHairLuke
Hi, l l am trying to make a simple guess program. This is my script: 

def main():
print ("Guess a letter between a and e")
randomNumber = b

userGuess = input("Your guess: ")

if userGuess == randomNumber:
 print("You got it")
else:
 print ("That's not it")

main()


When l run the program l get error: userGuess is not defined, but l defined 
userGuess at line 5. I don't get it someone plese help :) 

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


Re: Scripting Help please

2016-10-13 Thread Steven D'Aprano
On Thursday 13 October 2016 07:37, LongHairLuke wrote:

> Hi l am on my way to make a bot for the game Piano Tiles 2.
> But the code l have written so far saids invalid syntax at 2nd line. Here is
> my code:

Folks, look at the email address of the poster:

trolleri.trollface at gmail.com

He's posted code that doesn't look anything like Python code, and all but 
admitted to trolling us. I don't think we should be responding.




-- 
Steven
git gets easier once you get the basic idea that branches are homeomorphic 
endofunctors mapping submanifolds of a Hilbert space.

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


Re: Scripting Help please

2016-10-12 Thread Terry Reedy

On 10/12/2016 4:37 PM, LongHairLuke wrote:

Hi l am on my way to make a bot for the game Piano Tiles 2. But the
code l have written so far saids invalid syntax at 2nd line. Here is
my code:


If you want to write Python code, start by working through the tutorial 
included with the docs.


--
Terry Jan Reedy

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


Re: Scripting Help please

2016-10-12 Thread Wildman via Python-list
On Wed, 12 Oct 2016 20:48:31 +, alister wrote:

> On Wed, 12 Oct 2016 13:37:23 -0700, LongHairLuke wrote:
> 
>> Hi l am on my way to make a bot for the game Piano Tiles 2.
>> But the code l have written so far saids invalid syntax at 2nd line.
>> Here is my code:
>> 
>> 
>> 
>> while True:
>>If active then
>>   FFSnapShot(areaX, areaY + height - offsetBottom, areaX + width,
>>   areaY + height - offsetBottom, sid)
>>   For row = 0 To norows - 1
>>  c = FFGetPixel(areaX + row * rowWidth + 5, areaY + height -
>>  offsetBottom, sid)
>>  cs = _ColorGetRGB(c)
>>  b = ( cs[0] * 0.3 ) + ( cs[1] * 0.59 ) + ( cs[2] * 0.11 )
>>  If lock[row] Then
>> If b < darkness Then
>>ContinueLoop
>> Else
>>lock[row] = False
>> EndIf
>>  EndIf If b < darkness Then
>> MouseUp("Left")
>> lock[row] = True MouseMove(areaX + row * rowWidth + rowWidth
>> / 2, areaY + height - offsetBottom, 1)
>> MouseDown("Left")
>>  EndIf
>>   Next
>>EndIf
>> End
>> 
>> Can someone help me please?
> 
> Is observation this is not Python code
> it looks more like some variety of BASIC but I could easily be wrong

I looks very similar to Visual Basic except I know of no instances
where '[]' are used in an array, as in lock[row].  The functions
that begin with 'FF' are from a pixel search library called FastFind.
It works with several different programming languages so no definite
clue there.  I'm not sure about the Mouse functions.  They could also
be from a library.  In VB the functions would be called like this:
object.MouseUp().  I'm not sure what the code is but it definitely
is not Python.

-- 
 GNU/Linux user #557453
May the Source be with you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Scripting Help please

2016-10-12 Thread alister
On Wed, 12 Oct 2016 13:37:23 -0700, LongHairLuke wrote:

> Hi l am on my way to make a bot for the game Piano Tiles 2.
> But the code l have written so far saids invalid syntax at 2nd line.
> Here is my code:
> 
> 
> 
> while True:
>If active then
>   FFSnapShot(areaX, areaY + height - offsetBottom, areaX + width,
>   areaY + height - offsetBottom, sid)
>   For row = 0 To norows - 1
>  c = FFGetPixel(areaX + row * rowWidth + 5, areaY + height -
>  offsetBottom, sid)
>  cs = _ColorGetRGB(c)
>  b = ( cs[0] * 0.3 ) + ( cs[1] * 0.59 ) + ( cs[2] * 0.11 )
>  If lock[row] Then
> If b < darkness Then
>ContinueLoop
> Else
>lock[row] = False
> EndIf
>  EndIf If b < darkness Then
> MouseUp("Left")
> lock[row] = True MouseMove(areaX + row * rowWidth + rowWidth
> / 2, areaY + height - offsetBottom, 1)
> MouseDown("Left")
>  EndIf
>   Next
>EndIf
> End
> 
> Can someone help me please?

Is observation this is not Python code
it looks more like some variety of BASIC but I could easily be wrong



-- 
Regarding astral projection, Woody Allen once wrote, "This is not a bad 
way
to travel, although there is usually a half-hour wait for luggage."
-- 
https://mail.python.org/mailman/listinfo/python-list


Scripting Help please

2016-10-12 Thread LongHairLuke
Hi l am on my way to make a bot for the game Piano Tiles 2. 
But the code l have written so far saids invalid syntax at 2nd line. Here is my 
code: 



while True:
   If active then
  FFSnapShot(areaX, areaY + height - offsetBottom, areaX + width, areaY + 
height - offsetBottom, sid)
  For row = 0 To norows - 1
 c = FFGetPixel(areaX + row * rowWidth + 5, areaY + height - 
offsetBottom, sid)
 cs = _ColorGetRGB(c)
 b = ( cs[0] * 0.3 ) + ( cs[1] * 0.59 ) + ( cs[2] * 0.11 )
 If lock[row] Then
If b < darkness Then
   ContinueLoop
Else
   lock[row] = False
EndIf
 EndIf
 If b < darkness Then
MouseUp("Left")
lock[row] = True
MouseMove(areaX + row * rowWidth + rowWidth / 2, areaY + height - 
offsetBottom, 1)
MouseDown("Left")
 EndIf
  Next
   EndIf
End

Can someone help me please? 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: HELP PLEASE printing single characters!

2015-12-03 Thread Larry Hudson via Python-list

On 12/02/2015 04:08 PM, John Strick wrote:

On Wednesday, December 2, 2015 at 12:58:30 PM UTC-6, Dylan Riley wrote:

hi all,
I have been trying to figure out all day why my code is printing single 
characters from my list when i print random elements using random.choice the 
elements in the list are not single characters for example when i print, 
print(LIST[random.choice]) i get:
["e", "x", "a", "m", "p", "l", "e"] when i should get ["example"].

my code is:
#Create a program that prints a list of words in random order.
#The program should print all the words and not repeat any.

import random

LIST = ["blue ", "red ", "yellow ", "green ", "orange "]
order = []

print("This game will print a random order of colours")
print("The list is", LIST)
input("press enter to start")



while LIST != []:
 choice = random.choice(LIST)
 order += choice
 while choice in LIST:
 LIST.remove(choice)
print(order)



input("press enter to exit")

thanks in advance guys


You could just shuffle the list first, then loop through it. This will 
guarantee that each color is only used once.


Not quite.  Only if the original list has no repetitions.

My personal approach would be to use a set to eliminate the duplicates, convert back to a list 
and shuffle that.


no_reps = list(set(LIST))
random.shuffle(no_reps)
print(no_reps)   #  Or use loop to print one-per-line

 -=- Larry -=-

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


Re: HELP PLEASE printing single characters!

2015-12-02 Thread John Strick
On Wednesday, December 2, 2015 at 12:58:30 PM UTC-6, Dylan Riley wrote:
> hi all,
> I have been trying to figure out all day why my code is printing single 
> characters from my list when i print random elements using random.choice the 
> elements in the list are not single characters for example when i print, 
> print(LIST[random.choice]) i get:
> ["e", "x", "a", "m", "p", "l", "e"] when i should get ["example"].
> 
> my code is:
> #Create a program that prints a list of words in random order.
> #The program should print all the words and not repeat any.
> 
> import random
> 
> LIST = ["blue ", "red ", "yellow ", "green ", "orange "]
> order = []
> 
> print("This game will print a random order of colours")
> print("The list is", LIST)
> input("press enter to start")
> 
> 
> 
> while LIST != []:
> choice = random.choice(LIST)
> order += choice
> while choice in LIST:
> LIST.remove(choice)
> print(order)
> 
> 
> 
> input("press enter to exit")
> 
> thanks in advance guys

You could just shuffle the list first, then loop through it. This will 
guarantee that each color is only used once. 

import random
LIST = ["blue ", "red ", "yellow ", "green ", "orange "]
random.shuffle(LIST)
for color in LIST:
print(color)
# or add to order or whatever you need to

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


Re: HELP PLEASE printing single characters!

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 1:44 PM, Dylan Riley  wrote:
> hi ian what would be the correct code to use in this situation then because 
> as far as i am aware the elements of my list should be printed as whole 
> elements and not just characters of the elements.

order.append(choice)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: HELP PLEASE printing single characters!

2015-12-02 Thread Dylan Riley
On Wednesday, December 2, 2015 at 7:09:23 PM UTC, Ian wrote:
> On Wed, Dec 2, 2015 at 12:58 PM, Dylan Riley  wrote:
> > hi all,
> > I have been trying to figure out all day why my code is printing single 
> > characters from my list when i print random elements using random.choice 
> > the elements in the list are not single characters for example when i 
> > print, print(LIST[random.choice]) i get:
> > ["e", "x", "a", "m", "p", "l", "e"] when i should get ["example"].
> 
> Remember that strings are iterable, and that iterating over strings
> results in individual characters. That should give you a clue as to
> what's going on.
> 
> > my code is:
> > #Create a program that prints a list of words in random order.
> > #The program should print all the words and not repeat any.
> >
> > import random
> >
> > LIST = ["blue ", "red ", "yellow ", "green ", "orange "]
> > order = []
> >
> > print("This game will print a random order of colours")
> > print("The list is", LIST)
> > input("press enter to start")
> >
> >
> >
> > while LIST != []:
> > choice = random.choice(LIST)
> > order += choice
> 
> Addition on a list does concatenation, not appending. So this takes
> each element from choice and adds them individually to order.

hi ian what would be the correct code to use in this situation then because as 
far as i am aware the elements of my list should be printed as whole elements 
and not just characters of the elements.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: HELP PLEASE printing single characters!

2015-12-02 Thread Ian Kelly
On Wed, Dec 2, 2015 at 12:58 PM, Dylan Riley  wrote:
> hi all,
> I have been trying to figure out all day why my code is printing single 
> characters from my list when i print random elements using random.choice the 
> elements in the list are not single characters for example when i print, 
> print(LIST[random.choice]) i get:
> ["e", "x", "a", "m", "p", "l", "e"] when i should get ["example"].

Remember that strings are iterable, and that iterating over strings
results in individual characters. That should give you a clue as to
what's going on.

> my code is:
> #Create a program that prints a list of words in random order.
> #The program should print all the words and not repeat any.
>
> import random
>
> LIST = ["blue ", "red ", "yellow ", "green ", "orange "]
> order = []
>
> print("This game will print a random order of colours")
> print("The list is", LIST)
> input("press enter to start")
>
>
>
> while LIST != []:
> choice = random.choice(LIST)
> order += choice

Addition on a list does concatenation, not appending. So this takes
each element from choice and adds them individually to order.
-- 
https://mail.python.org/mailman/listinfo/python-list


HELP PLEASE printing single characters!

2015-12-02 Thread Dylan Riley
hi all,
I have been trying to figure out all day why my code is printing single 
characters from my list when i print random elements using random.choice the 
elements in the list are not single characters for example when i print, 
print(LIST[random.choice]) i get:
["e", "x", "a", "m", "p", "l", "e"] when i should get ["example"].

my code is:
#Create a program that prints a list of words in random order.
#The program should print all the words and not repeat any.

import random

LIST = ["blue ", "red ", "yellow ", "green ", "orange "]
order = []

print("This game will print a random order of colours")
print("The list is", LIST)
input("press enter to start")



while LIST != []:
choice = random.choice(LIST)
order += choice
while choice in LIST:
LIST.remove(choice)
print(order)



input("press enter to exit")

thanks in advance guys
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: new to python, help please !!

2015-11-12 Thread Denis McMahon
On Wed, 11 Nov 2015 08:34:30 -0800, Anas Belemlih wrote:

> i am  a beginning programmer,  i am trying to write a simple code to
> compare two character sets in 2 seperate files. ( 2 hash value files
> basically)

Why? If you simply wish to compare two files, most operating systems 
provide executable tools at the OS level which are more efficient than 
anything you will write in a scripting language.

Lesson 1 of computing. Use the right tool for the job. Writing a new 
program is not always the right tool.
-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: new to python, help please !!

2015-11-12 Thread Denis McMahon
On Thu, 12 Nov 2015 17:55:33 +, Quivis wrote:

> On Thu, 12 Nov 2015 13:58:35 +1100, Steven D'Aprano wrote:
> 
>> horribly inefficient
> 
> Assuming it was md5 values, who cares? Those are small.

A file of 160 million md5 hashes as 32 character hex strings is a huge 
file. Your method calculates the hash over both files to test whether the 
contents are different. If the input files are both lists of 160 million 
md5 hashes, you're calculating the hash of two 5 gigabyte files.

In your method the size of the lines of data is irrelevant to the 
execution time, the execution time varies with the size of the datafiles.
-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: new to python, help please !!

2015-11-12 Thread Peter Otten
Tim Chase wrote:

> On 2015-11-12 15:56, Peter Otten wrote:
>> Tim Chase wrote:
>> 
>> >   with open("file1.md5") as a, open("file2.md5") as b:
>> > for s1, s2 in zip(a, b):
>> >   if s1 != s2:
>> > print("Files differ")
>> 
>> Note that this will not detect extra lines in one of the files.
>> I recommend that you use itertools.zip_longest (izip_longest in
>> Python 2) instead of the built-in zip().
> 
> Yeah, I noticed that after pushing  but then posted a later
> version that just read chunks of the file which should catch that
> file-size difference.  Or, as in that other message, prefix it with
> an fstat() check to compare file-sizes so that you don't even have to
> open the files if the sizes differ.
> 
> -tkc

>>> os.path.getsize("file1.md5")
10
>>> os.path.getsize("file2.md5")
10
>>> with open("file1.md5") as a, open("file2.md5") as b:
... for s, t in zip(a, b):
... if s != t: print("different")
... 
>>> from itertools import zip_longest
>>> with open("file1.md5") as a, open("file2.md5") as b:
... for s, t in zip_longest(a, b):
... if s != t: print("different")
... 
different

I admit I cheated and used Python 3 ;)


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


Re: new to python, help please !!

2015-11-12 Thread Tim Chase
On 2015-11-12 15:56, Peter Otten wrote:
> Tim Chase wrote:
> 
> >   with open("file1.md5") as a, open("file2.md5") as b:
> > for s1, s2 in zip(a, b):
> >   if s1 != s2:
> > print("Files differ")
> 
> Note that this will not detect extra lines in one of the files.
> I recommend that you use itertools.zip_longest (izip_longest in
> Python 2) instead of the built-in zip().

Yeah, I noticed that after pushing  but then posted a later
version that just read chunks of the file which should catch that
file-size difference.  Or, as in that other message, prefix it with
an fstat() check to compare file-sizes so that you don't even have to
open the files if the sizes differ.

-tkc


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


Re: new to python, help please !!

2015-11-12 Thread Peter Otten
Tim Chase wrote:

>   with open("file1.md5") as a, open("file2.md5") as b:
> for s1, s2 in zip(a, b):
>   if s1 != s2:
> print("Files differ")

Note that this will not detect extra lines in one of the files.
I recommend that you use itertools.zip_longest (izip_longest in Python 2) 
instead of the built-in zip().

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


Re: new to python, help please !!

2015-11-12 Thread paul.hermeneutic
Would some form of subprocess.Popen() on cmp or fc /b be easier?
On Nov 12, 2015 7:13 AM, "Tim Chase"  wrote:

> On 2015-11-12 08:21, Marko Rauhamaa wrote:
> > And if you really wanted to compare two files that are known to
> > contain MD5 checksums, the simplest way is:
> >
> >with open('f1.md5') as f1, open('f2.md5') as f2:
> >if f1.read() == f2.read():
> >...
> >else:
> >...
>
> Though that suffers if the files are large.  Might try
>
>   CHUNK_SIZE = 4 * 1024 # read 4k chunks
>   # chunk_offset = 0
>   with open('f1.md5') as f1, open('f2.md5') as f2:
> while True:
>   c1 = f1.read(CHUNK_SIZE)
>   c2 = f2.read(CHUNK_SIZE)
>   if c1 or c2:
> # chunk_offset += 1
> if c1 != c2:
>   not_the_same(c1, c2)
>   # not_the_same(chunk_offset * CHUNK_SIZE, c1, c2)
>   break
>   else: # EOF
> the_same()
> break
>
> which should perform better if the files are huge
>
> -tkc
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: new to python, help please !!

2015-11-12 Thread Tim Chase
On 2015-11-12 08:21, Marko Rauhamaa wrote:
> And if you really wanted to compare two files that are known to
> contain MD5 checksums, the simplest way is:
> 
>with open('f1.md5') as f1, open('f2.md5') as f2:
>if f1.read() == f2.read():
>...
>else:
>...

Though that suffers if the files are large.  Might try

  CHUNK_SIZE = 4 * 1024 # read 4k chunks
  # chunk_offset = 0
  with open('f1.md5') as f1, open('f2.md5') as f2:
while True:
  c1 = f1.read(CHUNK_SIZE)
  c2 = f2.read(CHUNK_SIZE)
  if c1 or c2:
# chunk_offset += 1
if c1 != c2:
  not_the_same(c1, c2)
  # not_the_same(chunk_offset * CHUNK_SIZE, c1, c2)
  break
  else: # EOF
the_same()
break

which should perform better if the files are huge

-tkc



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


Re: new to python, help please !!

2015-11-11 Thread Marko Rauhamaa
Steven D'Aprano :

> On Thursday 12 November 2015 04:48, Quivis wrote:
>
>> On Wed, 11 Nov 2015 08:34:30 -0800, Anas Belemlih wrote:
>> 
>>> md5
>> 
>> If those are md5 values stored inside files, wouldn't it be easier to
>> just hash them?
>> 
>> import hashlib
>> 
>> m1 = hashlib.sha224(open('f1').read()).hexdigest()
>> m2 = hashlib.sha224(open('f2').read()).hexdigest()
>
> I presume that the purpose of the exercise is to learn basic Python
> skills like looping.

And if you really wanted to compare two files that are known to contain
MD5 checksums, the simplest way is:

   with open('f1.md5') as f1, open('f2.md5') as f2:
   if f1.read() == f2.read():
   ...
   else:
   ...


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


Re: new to python, help please !!

2015-11-11 Thread Steven D'Aprano
On Thursday 12 November 2015 04:48, Quivis wrote:

> On Wed, 11 Nov 2015 08:34:30 -0800, Anas Belemlih wrote:
> 
>> md5
> 
> If those are md5 values stored inside files, wouldn't it be easier to
> just hash them?
> 
> import hashlib
> 
> m1 = hashlib.sha224(open('f1').read()).hexdigest()
> m2 = hashlib.sha224(open('f2').read()).hexdigest()

I presume that the purpose of the exercise is to learn basic Python skills 
like looping.

Also, using sha224 when all you want is a simple "different"/"equal" is 
horribly inefficient. Sha224 needs to read the entire file, every single 
byte, *and* perform a bunch of expensive cryptographic operations. Consider 
reading two five GB files, the first starting with byte \x30 and the second 
starting with byte \x60. The two bytes are different, so we know the files 
differ, but sha224 still needs to do a massive amount of work.



-- 
Steve

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


Re: new to python, help please !!

2015-11-11 Thread Ben Finney
Anas Belemlih  writes:

> i am  a beginning programmer,  i am trying to write a simple code to
> compare two character sets in 2 seperate files. ( 2 hash value files
> basically)

Welcome, and congratulations on arriving at Python for your programming!

As a beginning programmer, you will benefit from joining the ‘tutor’
forum https://mail.python.org/mailman/listinfo/tutor>, which is
much better suited to collaborative teaching of newcomers.

-- 
 \ “As scarce as truth is, the supply has always been in excess of |
  `\   the demand.” —Josh Billings |
_o__)  |
Ben Finney

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


Re: new to python, help please !!

2015-11-11 Thread Tim Chase
On 2015-11-11 08:34, Anas Belemlih wrote:
> i am  a beginning programmer,  i am trying to write a simple code
> to compare two character sets in 2 seperate files. ( 2 hash value
> files basically) idea is: open both files, measure the length of
> the  loop on.
> 
> if the length doesn't match, ==  files do not  match
> 
> if length matchs, loop  while comparing each character from each
> file if they match. please tell me what i am doing wrong ?  i am
> using python 2.7
> 
> **
> hash1= open ("file1.md5", "r")
> line1 =hash1.read()
> hash2 = open("file2.md5","r")
> line2= hash2.read()
> 
> number1 = len(line1)
> number2 = len(line2)
> 
> #**
> i=0
> s1=line1[i]
> s2=line2[i]
> count = 0
> 
> if number1 != number2:
>   print " hash table not the same size"
> else:
> while count < number1:
>   if s1 == s2:
>   print " character", line1[i]," matchs"
>   i=i+1
>   count=count+1
>   else
>   print "Hash values corrupt"

Well, the immediate answer is that you don't update s1 or s2 inside
your loop.  Also, the indent on "count=count+1" is wrong.  Finally,
if the hashes don't match, you don't break out of your while loop.
That said, the pythonesque way of writing this would likely look
something much more like

  with open("file1.md5") as a, open("file2.md5") as b:
for s1, s2 in zip(a, b):
  if s1 != s2:
print("Files differ")

You can compare the strings to get the actual offset if you want, or
check the lengths if you really want a more verbatim translation of
your code:

  with open("file1.md5") as a, open("file2.md5") as b:
for s1, s2 in zip(a, b):
  if len(s1) != len(s2):
print("not the same size")
  else:
for i, (c1, c2) in enumerate(zip(s1, s2)):
  if c1 == c2:
print(" character %s matches" %  c1)
  else:
print(" %r and %r differ at position %i" % (s1, s2, i))

-tkc



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


Re: new to python, help please !!

2015-11-11 Thread John Gordon
In <93aef8e5-3d6f-41f4-a625-cd3c20076...@googlegroups.com> Anas Belemlih 
 writes:

> i=0
> s1=line1[i]
> s2=line2[i]
> count = 0

> if number1 != number2:
>   print " hash table not the same size"
> else:
> while count < number1:
>   if s1 == s2:
>   print " character", line1[i]," matchs"
>   i=i+1
>   count=count+1
>   else
>   print "Hash values corrupt"

It looks like you're expecting s1 and s2 to automatically update their
values when i gets incremented, but it doesn't work like that.  When you
increment i, you also have to reassign s1 and s2.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


new to python, help please !!

2015-11-11 Thread Anas Belemlih
i am  a beginning programmer,  i am trying to write a simple code to compare 
two character sets in 2 seperate files. ( 2 hash value files basically)
idea is:
 open both files, measure the length of the  loop on.

if the length doesn't match, ==  files do not  match

if length matchs, loop  while comparing each character from each file if they 
match. 
 please tell me what i am doing wrong ?  i am using python 2.7

**
hash1= open ("file1.md5", "r")
line1 =hash1.read()
hash2 = open("file2.md5","r")
line2= hash2.read()

number1 = len(line1)
number2 = len(line2)

#**
i=0
s1=line1[i]
s2=line2[i]
count = 0

if number1 != number2:
print " hash table not the same size"
else:
while count < number1:
if s1 == s2:
print " character", line1[i]," matchs"
i=i+1
count=count+1
else
print "Hash values corrupt"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: help please: tkinter grid layout is very slow

2014-11-13 Thread Chris Angelico
On Fri, Nov 14, 2014 at 7:45 AM, Rich Cook  wrote:
> print "There are", numimages, "images"  # 256 in fact...
> for imagenum, (row, col) in enumerate([(row,col) for row in range(numrows) 
> for col in range(numcols)]):
> b = Tkinter.Label(frame, compound = Tkinter.TOP)
> b['text'] = os.path.basename(image_list[imagenum])
> b['image'] = ImageTk.PhotoImage(Image.open(image_list[imagenum]) )

You're asking someone somewhere to load 256 images into memory and
display them. What's the resolution of these images? Do they need to
be scaled/cropped? That can be fairly expensive. How long does it
actually take to (a) load all those images, and (b) pack the frame?
Try, for instance, commenting out the b.grid() call, to force them all
to be loaded but not packed.

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


Re: help please: tkinter grid layout is very slow

2014-11-13 Thread Terry Reedy

On 11/13/2014 3:45 PM, Rich Cook wrote:

Hi, I'm trying to toss together an image browser in tkinter, and it is so slow 
it is unworkable.  Here is my code.  Can someone point out why it's so slw? 
 :-)  Thanks

root = Tkinter.Tk()
root.geometry("1000x280+300+300")
label = Tkinter.Button(root, compound=Tkinter.TOP)
label.pack()

numimages = len(image_list)
numcols = 6
numrows = numimages/numcols


That should be numimages // numcols


if numrows * numcols != numimages:
 numrows += 1

frame = Tkinter.Frame(root)
for col in range(numcols):
 frame.columnconfigure(col, pad=2)

for row in range(numrows):
 frame.rowconfigure(row, pad=2)

print "There are", numimages, "images"  # 256 in fact...
for imagenum, (row, col) in enumerate([(row,col) for row in range(numrows) for 
col in range(numcols)]):
 b = Tkinter.Label(frame, compound = Tkinter.TOP)
 b['text'] = os.path.basename(image_list[imagenum])
 b['image'] = ImageTk.PhotoImage(Image.open(image_list[imagenum]) )


ImageTk? or Tkinter?


 b.grid(row=row, column = col)

frame.pack()

root.mainloop()




--
Terry Jan Reedy

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


help please: tkinter grid layout is very slow

2014-11-13 Thread Rich Cook
Hi, I'm trying to toss together an image browser in tkinter, and it is so slow 
it is unworkable.  Here is my code.  Can someone point out why it's so slw? 
 :-)  Thanks

root = Tkinter.Tk()
root.geometry("1000x280+300+300")
label = Tkinter.Button(root, compound=Tkinter.TOP)
label.pack()

numimages = len(image_list)
numcols = 6
numrows = numimages/numcols
if numrows * numcols != numimages:
numrows += 1

frame = Tkinter.Frame(root)
for col in range(numcols):
frame.columnconfigure(col, pad=2)

for row in range(numrows):
frame.rowconfigure(row, pad=2)

print "There are", numimages, "images"  # 256 in fact... 
for imagenum, (row, col) in enumerate([(row,col) for row in range(numrows) for 
col in range(numcols)]):
b = Tkinter.Label(frame, compound = Tkinter.TOP)
b['text'] = os.path.basename(image_list[imagenum])
b['image'] = ImageTk.PhotoImage(Image.open(image_list[imagenum]) )
b.grid(row=row, column = col)

frame.pack()

root.mainloop()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Development infrastructure - need python packaging gurus help, please

2014-01-28 Thread dieter
Eugene Sajine  writes:
> ...
> Here is what i'm trying to achieve:
> 1. I want to be able to specify the set of dependencies for the project i'm 
> currently developing and make them available for the import. Think java jar - 
> having it in class path allows for the code reuse (import packages provided) 
> as well as for the execution.
> 2. I want to be able to put the newly created project in a form of artifact 
> in a some central location from which it can be taken to be imported or 
> executed or included into "class path". Again think java jar. If i have it in 
> some location i can use ivy or maven to manage the dependencies and provide 
> it to me upon request
> 3. I want to be able to deploy the program and execute it.

You may have a look at "zc.buildout" - it may support your
development needs.

Once the development is complete, a so called "meta-egg" may
be used to describe the finished program. A "meta-egg" does not
have (significant amounts of) code but essentially states
dependencies of other eggs.

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


Development infrastructure - need python packaging gurus help, please

2014-01-28 Thread Eugene Sajine
Hi!

I'm trying to create a development infrastructure that would allow for simple 
and unified ways of sharing, *deploying* and *reusing* the code within private 
entity. I can see that pip with virtual environments and requirements.txt is 
very similar to dependency management provided by maven or apache ivy. But 
there seems to be a disconnect between the egg carrying the possibility to be 
importable and executable, but in the same time considered to be deprecated 
format which is not fully supported by pip and virtualenv and wheel not having 
those basic questions answered...

Here is what i'm trying to achieve:
1. I want to be able to specify the set of dependencies for the project i'm 
currently developing and make them available for the import. Think java jar - 
having it in class path allows for the code reuse (import packages provided) as 
well as for the execution.
2. I want to be able to put the newly created project in a form of artifact in 
a some central location from which it can be taken to be imported or executed 
or included into "class path". Again think java jar. If i have it in some 
location i can use ivy or maven to manage the dependencies and provide it to me 
upon request
3. I want to be able to deploy the program and execute it.

So the problem with all this as i see it:
The importable and executable format is egg, but it is deprecated!
Sane dependency management is pip and virtualenv, but they don't support eggs 
fully (pip install --egg is having the disclaimer that it s not working ok 
sometimes) wheel is pretty much unusable for anything other then installing 
into the virtualenv.

Am i missing something?

Thanks in advance,
Eugene
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread MRAB
On 23/11/2013 22:29, Bhanu Karthik wrote:> On Saturday, 23 November 2013 
14:23:08 UTC-8, Chris Angelico  wrote:

>> On Sun, Nov 24, 2013 at 9:15 AM, Bhanu Karthik
>>  wrote:
>> > data = sock.recv(RECV_BUFFER)
>> > username = str(sock.getpeername())
>> > username = usernames[username]
>> > if command == "/quit":
>> > print data
>> > sock.send("bye")
>> > sock.close()
>> > CONNECTION_LIST.remove(sock)
>> >
>> > even if the received data is '/quit' the if condition not 
excuting...please help.

>>
>> At what point is command set? You're setting data here; is command
>> supposed to be derived from data?
>>
>> This looks like a MUD or IRC style of server, which would suggest that
>> commands are terminated by end-of-line. You may need to take content
>> from the socket (currently in data) and split it off on either "\r\n"
>> or "\n". But it's hard to tell from this small snippet.
>>
>> ChrisA
>
> sorry its not command its data
>
> I miss wrote it here...
>
If the 'if' condition not executing then it must be because the
received data isn't "/quit", so what is it? Print it out, or, even
better, print out repr(data), which will show you any spaces or "\n" in
it.

sock.recv(RECV_BUFFER) will receive up to RECV_BUFFER bytes, so if the
sender is sending other stuff after the "/quit" and RECV_BUFFER > 5,
then you might be receiving some of that later stuff too.

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


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Chris Angelico
On Sun, Nov 24, 2013 at 9:39 AM, Bhanu Karthik
 wrote:
> indentation is correct when I trying to paste it here,it is showing like it 
> is unindented.

That's because Google Groups mucks things up. Get a better client.

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


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Bhanu Karthik
On Saturday, 23 November 2013 14:37:09 UTC-8, Roy Smith  wrote:
> In article <8445e47e-7efe-4f37-9b40-db2896d58...@googlegroups.com>,
> 
>  Bhanu Karthik  wrote:
> 
> 
> 
> >  data = sock.recv(RECV_BUFFER)
> 
> > username = str(sock.getpeername())
> 
> > username = usernames[username]  
> 
> > if data == "/quit":
> 
> > print data
> 
> > sock.send("bye")
> 
> > sock.close()
> 
> > CONNECTION_LIST.remove(sock)
> 
> > 
> 
> > 
> 
> > this is exact code..
> 
> > it is not even entering the if ...
> 
> > I tried ( c= (data is '/quit')if c)
> 
> 
> 
> That can't be the exact code.  What you posted is a syntax error because 
> 
> the line after the "if" statement isn't indented properly.

indentation is correct when I trying to paste it here,it is showing like it is 
unindented.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Chris Angelico
On Sun, Nov 24, 2013 at 9:33 AM, Bhanu Karthik
 wrote:
> this is exact code..
> it is not even entering the if ...
> I tried ( c= (data is '/quit')if c)
>
> when i print c ,its printing falseI dont understand what is 
> happening...please help..

Again, please get off Google Groups. Have a look at how your posts come out:

https://mail.python.org/pipermail/python-list/2013-November/661005.html

Note how your quoted text is double-spaced. This is one of the most
obvious and obnoxious problems, though not the only one.

You have two problems here. Firstly, comparing strings with 'is' is
wrong in most cases[1], so stick with ==. And secondly, my crystal
ball says that you're typing "/quit" and pressing enter, so your
socket read will be "/quit\r\n" or "/quit\n". To properly handle this,
you'll need to buffer and split as I was describing.

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


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Roy Smith
In article <8445e47e-7efe-4f37-9b40-db2896d58...@googlegroups.com>,
 Bhanu Karthik  wrote:

>  data = sock.recv(RECV_BUFFER)
>   username = str(sock.getpeername())
>   username = usernames[username]  
>   if data == "/quit":
>   print data
>   sock.send("bye")
>   sock.close()
>   CONNECTION_LIST.remove(sock)
> 
> 
> this is exact code..
> it is not even entering the if ...
> I tried ( c= (data is '/quit')if c)

That can't be the exact code.  What you posted is a syntax error because 
the line after the "if" statement isn't indented properly.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Bhanu Karthik
On Saturday, 23 November 2013 14:23:08 UTC-8, Chris Angelico  wrote:
> On Sun, Nov 24, 2013 at 9:15 AM, Bhanu Karthik
> 
>  wrote:
> 
> > data = sock.recv(RECV_BUFFER)
> 
> > username = str(sock.getpeername())
> 
> > username = usernames[username]
> 
> > if command == "/quit":
> 
> > print data
> 
> > sock.send("bye")
> 
> > sock.close()
> 
> > CONNECTION_LIST.remove(sock)
> 
> >
> 
> > even if the received data is '/quit' the if condition not excuting...please 
> > help.
> 
> 
> 
> At what point is command set? You're setting data here; is command
> 
> supposed to be derived from data?
> 
> 
> 
> This looks like a MUD or IRC style of server, which would suggest that
> 
> commands are terminated by end-of-line. You may need to take content
> 
> from the socket (currently in data) and split it off on either "\r\n"
> 
> or "\n". But it's hard to tell from this small snippet.
> 
> 
> 
> ChrisA

 data = sock.recv(RECV_BUFFER)
username = str(sock.getpeername())
username = usernames[username]  
if data == "/quit":
print data
sock.send("bye")
sock.close()
CONNECTION_LIST.remove(sock)


this is exact code..
it is not even entering the if ...
I tried ( c= (data is '/quit')if c)

when i print c ,its printing falseI dont understand what is 
happening...please help..
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Chris Angelico
On Sun, Nov 24, 2013 at 9:29 AM, Bhanu Karthik
 wrote:
> sorry its not command its data
>
> I miss wrote it here...

Okay. Start by copying and pasting your actual code, and saying what
you're doing to trigger it. If this is a stream socket (eg TCP), you
have no way of knowing where one read will end and the next start, so
you'll need to do some kind of buffering and splitting.

Also, please use something better than Google Groups; your posts are
looking rather ugly, and it's the fault of your client rather than
yourself.

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


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Bhanu Karthik
On Saturday, 23 November 2013 14:23:08 UTC-8, Chris Angelico  wrote:
> On Sun, Nov 24, 2013 at 9:15 AM, Bhanu Karthik
> 
>  wrote:
> 
> > data = sock.recv(RECV_BUFFER)
> 
> > username = str(sock.getpeername())
> 
> > username = usernames[username]
> 
> > if command == "/quit":
> 
> > print data
> 
> > sock.send("bye")
> 
> > sock.close()
> 
> > CONNECTION_LIST.remove(sock)
> 
> >
> 
> > even if the received data is '/quit' the if condition not excuting...please 
> > help.
> 
> 
> 
> At what point is command set? You're setting data here; is command
> 
> supposed to be derived from data?
> 
> 
> 
> This looks like a MUD or IRC style of server, which would suggest that
> 
> commands are terminated by end-of-line. You may need to take content
> 
> from the socket (currently in data) and split it off on either "\r\n"
> 
> or "\n". But it's hard to tell from this small snippet.
> 
> 
> 
> ChrisA

sorry its not command its data

I miss wrote it here...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: stuck at this from so much time,need help....please ..

2013-11-23 Thread Chris Angelico
On Sun, Nov 24, 2013 at 9:15 AM, Bhanu Karthik
 wrote:
> data = sock.recv(RECV_BUFFER)
> username = str(sock.getpeername())
> username = usernames[username]
> if command == "/quit":
> print data
> sock.send("bye")
> sock.close()
> CONNECTION_LIST.remove(sock)
>
> even if the received data is '/quit' the if condition not excuting...please 
> help.

At what point is command set? You're setting data here; is command
supposed to be derived from data?

This looks like a MUD or IRC style of server, which would suggest that
commands are terminated by end-of-line. You may need to take content
from the socket (currently in data) and split it off on either "\r\n"
or "\n". But it's hard to tell from this small snippet.

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


stuck at this from so much time,need help....please ..

2013-11-23 Thread Bhanu Karthik
data = sock.recv(RECV_BUFFER)
username = str(sock.getpeername())
username = usernames[username]  
if command == "/quit":
print data
sock.send("bye")
sock.close()
CONNECTION_LIST.remove(sock)

even if the received data is '/quit' the if condition not excuting...please 
help.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Some python newb help please?

2013-11-12 Thread Chris Angelico
On Wed, Nov 13, 2013 at 10:04 AM,   wrote:
> Thanks a lot! I'll try this out!
> Sorry to everyone else whose eyes I made bleed. I've never used a newsgroup 
> before...still not really sure what they are. Found this through a google 
> search :\

There's an easy fix. Go to this page:

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

You can then subscribe to the mailing list using whatever email
address you're comfortable with. I use Gmail, which works fairly well
but has its own issues; I've glanced at Evolution (a Linux mail
client) and its way of handling threads, and it seems to do a good
job. Plenty of options.

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


Re: Some python newb help please?

2013-11-12 Thread Denis McMahon
On Tue, 12 Nov 2013 14:14:42 -0800, lrwarren94 wrote:

> http://pastebin.com/6QZTvx6Z

Work through your code very very carefully. You're doing something in 
each if branch that you probably only want to do once in each execution 
of the while loop.

If you can't figure it out, I'll post a corrected version next week.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Some python newb help please?

2013-11-12 Thread lrwarren94
On Tuesday, November 12, 2013 4:56:35 PM UTC-6, MRAB wrote:
> On 12/11/2013 22:27, l...@gmail.com wrote:> On Tuesday, November 
> 
> 12, 2013 4:21:58 PM UTC-6, Mark Lawrence wrote:
> 
>  >> On 12/11/2013 22:14, lr@gmail.com wrote:
> 
>  >>
> 
>  >> > So I'm trying to write a program for a problem in class, and 
> 
> something strange is happening that I can't figure out why is happening. 
> 
> I was wondering if you guys could help me fix it?
> 
>  >> >
> 
> [snip]
> 
>  >
> 
>  > x = 0
> 
>  > y = 0
> 
>  > quitCommand = 0
> 
>  >
> 
>  > print "Welcome to the World of Textcraft!"
> 
>  > print "--"
> 
>  > print ""
> 
> 
> 
> You can simplify that to:
> 
> 
> 
>  print
> 
> 
> 
>  >
> 
>  > while quitCommand != int(5):
> 
> 
> 
> 5 is already an int, so int(5) == 5.
> 
> 
> 
>  >  print "You are currently at (" + str(x) + ", " + str(y) + ")"
> 
>  >  print "Enter a command (1 = North, 2 = East, 3 = South, 4 = 
> 
> West, 5 = Exit):"
> 
>  >  if int(raw_input()) == 1:
> 
> 
> 
> You're asking the user to enter something and then checking whether its 
> 
> int value is 1.
> 
> 
> 
>  >  print "Moving north"
> 
>  >  y = y + 1
> 
>  >  elif int(raw_input()) == 2:
> 
> 
> 
> Now you're asking the user to enter something _again_ and then checking 
> 
> whether its int value is 2.
> 
> 
> 
> In other words, in order for it to print "Moving east" the following 
> 
> steps must occur:
> 
> 
> 
> 1. Ask the user to enter something.
> 
> 
> 
> 2. Check whether it's 1. It isn't. (Previous condition)
> 
> 
> 
> 3. Ask the user to enter something.
> 
> 
> 
> 4. Check whether it's 2. (This condition)
> 
> 
> 
>  >  print "Moving east"
> 
>  >  x = x + 1
> 
>  >  elif int(raw_input()) == 3:
> 
> 
> 
> Similar remarks to above, but longer.
> 
> 
> 
>  >  print "Moving south"
> 
>  >  y = y - 1
> 
>  >  elif int(raw_input()) == 4:
> 
> 
> 
> Similar remarks to above, but longer again.
> 
> 
> 
>  >  print "Moving west"
> 
>  >  x = x - 1
> 
>  >  elif int(raw_input()) == 5:
> 
> 
> 
> Similar remarks to above, but longer again.
> 
> 
> 
>  >  print "Dost thou leave so soon? Fare thee well!"
> 
>  >  quitCommand = 5
> 
>  >  else:
> 
>  >  print "I find your lack of reading comprehension skills 
> 
> disturbing."
> 
>  >
> 
> 
> 
> The fix is simple. Ask once:
> 
> 
> 
>   answer = int(raw_input())
> 
>   if answer == 1:
> 
>   ...
> 
>   elif answer == 2:
> 
>   ...
> 
>   ...

Thanks a lot! I'll try this out!
Sorry to everyone else whose eyes I made bleed. I've never used a newsgroup 
before...still not really sure what they are. Found this through a google 
search :\
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Some python newb help please?

2013-11-12 Thread Chris Angelico
On Wed, Nov 13, 2013 at 9:27 AM,   wrote:
> I'm not quite sure what you mean by that. it was on that pastebin link. I'll 
> post it again here though. it's no longer than half a page.

Inline means what you did in this post. Out-of-line means providing us
with a link to where the code is.

This forum isn't just a Google Groups web-based discussion group; it's
primarily a newsgroup (comp.lang.python) and an email address
(python-list@python.org). Both of those can be read by people who
don't have internet access, so putting your code in an http link might
prevent them from reading it. Also, the group/list gets archived all
over the place, and there's no guarantee that pastebin will still be
around a hundred years from now. It's an unnecessary dependency, which
inline code doesn't have. That's why posting right here is the safe
option :)

Two general comments. Firstly, you're using Python 2 here. Is there a
reason for that? If you possibly can, switch to Python 3. All sorts of
things have been improved, and the gap is only going to widen - there
won't be a Python 2.8, and subsequent 2.7.x releases are bugfixes and
security patches only. All the new shinies are in 3.x. And secondly,
please PLEASE avoid Google Groups; your quoted text is ugly and
annoying, and your own text isn't wrapped. Check this out, and
preferably, find an alternative means of posting:

https://wiki.python.org/moin/GoogleGroupsPython

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


Re: Some python newb help please?

2013-11-12 Thread MRAB
On 12/11/2013 22:27, lrwarre...@gmail.com wrote:> On Tuesday, November 
12, 2013 4:21:58 PM UTC-6, Mark Lawrence wrote:

>> On 12/11/2013 22:14, lr@gmail.com wrote:
>>
>> > So I'm trying to write a program for a problem in class, and 
something strange is happening that I can't figure out why is happening. 
I was wondering if you guys could help me fix it?

>> >
[snip]
>
> x = 0
> y = 0
> quitCommand = 0
>
> print "Welcome to the World of Textcraft!"
> print "--"
> print ""

You can simplify that to:

print

>
> while quitCommand != int(5):

5 is already an int, so int(5) == 5.

>  print "You are currently at (" + str(x) + ", " + str(y) + ")"
>  print "Enter a command (1 = North, 2 = East, 3 = South, 4 = 
West, 5 = Exit):"

>  if int(raw_input()) == 1:

You're asking the user to enter something and then checking whether its 
int value is 1.


>  print "Moving north"
>  y = y + 1
>  elif int(raw_input()) == 2:

Now you're asking the user to enter something _again_ and then checking 
whether its int value is 2.


In other words, in order for it to print "Moving east" the following 
steps must occur:


1. Ask the user to enter something.

2. Check whether it's 1. It isn't. (Previous condition)

3. Ask the user to enter something.

4. Check whether it's 2. (This condition)

>  print "Moving east"
>  x = x + 1
>  elif int(raw_input()) == 3:

Similar remarks to above, but longer.

>  print "Moving south"
>  y = y - 1
>  elif int(raw_input()) == 4:

Similar remarks to above, but longer again.

>  print "Moving west"
>  x = x - 1
>  elif int(raw_input()) == 5:

Similar remarks to above, but longer again.

>  print "Dost thou leave so soon? Fare thee well!"
>  quitCommand = 5
>  else:
>  print "I find your lack of reading comprehension skills 
disturbing."

>

The fix is simple. Ask once:

 answer = int(raw_input())
 if answer == 1:
 ...
 elif answer == 2:
 ...
 ...
--
https://mail.python.org/mailman/listinfo/python-list


Re: Some python newb help please?

2013-11-12 Thread Tim Chase
On 2013-11-12 14:27, lrwarre...@gmail.com wrote:
> if int(raw_input()) == 1:
> print "Moving north"
> y = y + 1
> elif int(raw_input()) == 2:
> print "Moving east"
> x = x + 1
> elif int(raw_input()) == 3:
> print "Moving south"
> y = y - 1
> elif int(raw_input()) == 4:
> print "Moving west"
> x = x - 1
> elif int(raw_input()) == 5:
> print "Dost thou leave so soon? Fare thee well!"
> quitCommand = 5
> else:
> print "I find your lack of reading comprehension skills
> disturbing."

Note that you're asking for input with each comparison.  Best to get
the input once and store it in a variable before the "if" statement
and then do the comparisons against the same value.

-tkc

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


Re: Some python newb help please?

2013-11-12 Thread Mark Lawrence
First thing would you please read and action this 
https://wiki.python.org/moin/GoogleGroupsPython so we don't have to read 
double spaced google crap, thanks.


On 12/11/2013 22:27, lrwarre...@gmail.com wrote:

On Tuesday, November 12, 2013 4:21:58 PM UTC-6, Mark Lawrence wrote:

On 12/11/2013 22:14, lr@gmail.com wrote:


So I'm trying to write a program for a problem in class, and something strange 
is happening that I can't figure out why is happening. I was wondering if you 
guys could help me fix it?







http://pastebin.com/6QZTvx6Z







Basically, 1 and 2 work just fine as inputs, but whenever I input 3 or 4, idle 
just doesn't do anything. Does anyone know why that is? any suggestions on how 
to fix? Any help is much appreciated :)








Please put your code inline so we can see it, if it's too long see this

http://sscce.org/ for advice.



--

Python is the second best programming language in the world.

But the best has yet to be invented.  Christian Tismer



Mark Lawrence


I'm not quite sure what you mean by that. it was on that pastebin link. I'll 
post it again here though. it's no longer than half a page.

x = 0
y = 0
quitCommand = 0

print "Welcome to the World of Textcraft!"
print "--"
print ""


You don't need the double quotes in the line above, the print statement 
on its own will output a newline.




while quitCommand != int(5):
 print "You are currently at (" + str(x) + ", " + str(y) + ")"
 print "Enter a command (1 = North, 2 = East, 3 = South, 4 = West, 5 = 
Exit):"
 if int(raw_input()) == 1:
 print "Moving north"
 y = y + 1
 elif int(raw_input()) == 2:
 print "Moving east"
 x = x + 1
 elif int(raw_input()) == 3:
 print "Moving south"
 y = y - 1
 elif int(raw_input()) == 4:
 print "Moving west"
 x = x - 1
 elif int(raw_input()) == 5:
 print "Dost thou leave so soon? Fare thee well!"
 quitCommand = 5
 else:
 print "I find your lack of reading comprehension skills 
disturbing."




You're asking for input in every comparison.  Change this to request the 
input once, store it and then compare it.  If you rename quitCommand to 
command, you'd have


command = int(raw_input())
if command == 1:
etc.

Enjoy :)

--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: Some python newb help please?

2013-11-12 Thread John Strick
Welcome to the world of Python programming! I'm glad you're learning this great 
language. 

As to your bug, think about this: in each if or elif statement, you're reading 
the user input again, so if user input is NOT equal to 1 in the first place, it 
reads input again. Try to step through your code mentally, or even on paper, 
and track *exactly* what's happening. You could also add some print statements 
to see where you are. Good luck with your coding.

Consider reading user input only once, and then checking it against the values 
1,2,3,4, and 5.

As an aside, "int(5)" is from the department of redundancy department. ;-)

--John Strickler

On Tuesday, November 12, 2013 5:14:42 PM UTC-5, lrwar...@gmail.com wrote:
> So I'm trying to write a program for a problem in class, and something 
> strange is happening that I can't figure out why is happening. I was 
> wondering if you guys could help me fix it?
> 
> 
> 
> http://pastebin.com/6QZTvx6Z
> 
> 
> 
> Basically, 1 and 2 work just fine as inputs, but whenever I input 3 or 4, 
> idle just doesn't do anything. Does anyone know why that is? any suggestions 
> on how to fix? Any help is much appreciated :)

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


Re: Some python newb help please?

2013-11-12 Thread lrwarren94
On Tuesday, November 12, 2013 4:21:58 PM UTC-6, Mark Lawrence wrote:
> On 12/11/2013 22:14, lr@gmail.com wrote:
> 
> > So I'm trying to write a program for a problem in class, and something 
> > strange is happening that I can't figure out why is happening. I was 
> > wondering if you guys could help me fix it?
> 
> >
> 
> > http://pastebin.com/6QZTvx6Z
> 
> >
> 
> > Basically, 1 and 2 work just fine as inputs, but whenever I input 3 or 4, 
> > idle just doesn't do anything. Does anyone know why that is? any 
> > suggestions on how to fix? Any help is much appreciated :)
> 
> >
> 
> 
> 
> Please put your code inline so we can see it, if it's too long see this 
> 
> http://sscce.org/ for advice.
> 
> 
> 
> -- 
> 
> Python is the second best programming language in the world.
> 
> But the best has yet to be invented.  Christian Tismer
> 
> 
> 
> Mark Lawrence

I'm not quite sure what you mean by that. it was on that pastebin link. I'll 
post it again here though. it's no longer than half a page. 

x = 0
y = 0
quitCommand = 0

print "Welcome to the World of Textcraft!"
print "--"
print ""

while quitCommand != int(5):
print "You are currently at (" + str(x) + ", " + str(y) + ")"
print "Enter a command (1 = North, 2 = East, 3 = South, 4 = West, 5 = 
Exit):"
if int(raw_input()) == 1:
print "Moving north"
y = y + 1
elif int(raw_input()) == 2:
print "Moving east"
x = x + 1
elif int(raw_input()) == 3:
print "Moving south"
y = y - 1
elif int(raw_input()) == 4:
print "Moving west"
x = x - 1
elif int(raw_input()) == 5:
print "Dost thou leave so soon? Fare thee well!"
quitCommand = 5
else:
print "I find your lack of reading comprehension skills disturbing."


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


Re: Some python newb help please?

2013-11-12 Thread Mark Lawrence

On 12/11/2013 22:14, lrwarre...@gmail.com wrote:

So I'm trying to write a program for a problem in class, and something strange 
is happening that I can't figure out why is happening. I was wondering if you 
guys could help me fix it?

http://pastebin.com/6QZTvx6Z

Basically, 1 and 2 work just fine as inputs, but whenever I input 3 or 4, idle 
just doesn't do anything. Does anyone know why that is? any suggestions on how 
to fix? Any help is much appreciated :)



Please put your code inline so we can see it, if it's too long see this 
http://sscce.org/ for advice.


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Some python newb help please?

2013-11-12 Thread lrwarren94
So I'm trying to write a program for a problem in class, and something strange 
is happening that I can't figure out why is happening. I was wondering if you 
guys could help me fix it?

http://pastebin.com/6QZTvx6Z

Basically, 1 and 2 work just fine as inputs, but whenever I input 3 or 4, idle 
just doesn't do anything. Does anyone know why that is? any suggestions on how 
to fix? Any help is much appreciated :)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help please, why doesn't it show the next input?

2013-09-13 Thread William Bryant
Thanks for the contructive critisism - :D I'll try fix it up!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help please, why doesn't it show the next input?

2013-09-13 Thread MRAB

On 13/09/2013 23:12, William Bryant wrote:

On Thursday, September 12, 2013 9:39:33 PM UTC+12, Oscar Benjamin wrote:

On 12 September 2013 07:04, William Bryant  wrote:

> Thanks everyone for helping but I did listen to you :3 Sorry. This is my 
code, it works, I know it's not the best way to do it and it's the long way round 
but it is one of my first programs ever and I'm happy with it:



Hi William, I'm glad you've solved your initial problem and I just

wanted to make a couple of comments about how your program could be

simplified or improved. The comments are below.



Hello, I've done this so far but why doesn't the mode function work?

'''#*'''
#* Name:Mode-Median-Mean Calculator   *#
#**#
#* Purpose: To calculate the mode, median and mean of a list of numbers   *#
#*  and the mode of a list of strings because that is what we are *#
#*  learning in math atm in school :P *#
#**#
#* Author:  William Bryant*#
#**#
#* Created: 11/09/2013*#
#**#
#* Copyright:   (c) William 2013  *#
#**#
#* Licence: IDK :3*#
'''**'''




#-#   ~~Import things I am using~~   #-#

# |
#|
#   \/

import time
import itertools



#-#~~Variables that I am using, including the list.~~#-#

# |
#|
#   \/


Global variables and no parameter passing: yuck! :-)


List = []
NumberOfXItems = []
Themode = []

#-#   ~~Functions that I am using.~~ #-#

# |
#|
#   \/


Your function names aren't meaningful.


def HMNs():
 global TheStr, user_inputHMNs, List_input, List
 user_inputHMNs = input("You picked string. This program cannot calculate the 
mean or median, but it can calculate the mode. :D  How many strings are you using in your 
list? (Can not be a decimal number)  \nEnter:  ")


This line doesn't do anything:


 user_inputHMNs
 time.sleep(1.5)


This variable is an integer, yet it's called 'TheStr'.


 TheStr = int(user_inputHMNs)
 for i in range(TheStr):
 List_input = input("Enter your strings. (One in each input field):  ")
 List.append(List_input)
 print("Your list -> ", List)


Here you're comparing the list's .count method with an integer. It'll 
never be true!



 if List.count == int(user_inputHMNs):
 break
 mode()

def HMNn():
 global TheNum, user_inputHMNn, List_input, List
 user_inputHMNn = input("You picked number. :D How many numbers are you using in 
your list? (Can not be a decimal number) \nEnter:  ")
 user_inputHMNn
 time.sleep(1.5)
 TheNum = int(user_inputHMNn)
 for i in range(TheNum):
 List_input = input("Enter your numbers. (One in each input field):  ")
 List_input = int(List_input)
 List.append(List_input)
 print("Your list -> ", List)


The same bug as above:


 if List.count == int(user_inputHMNn):
 break
 mode()
def NOS():
 while True: # Loops forever (until the break)
 answer = input("Does your list contain a number or a string?  \nEnter: 
")
 answer = answer.lower()
 if answer in ("string", "str", "s"):
 HMNs()
 break
 elif answer in ("number", "num", "n", "int"):
 HMNn()
 break
 elif answer in ("quit", "q"):
 break  # Exits the while loop
 else:
 print("You did not enter a valid field, :P Sorry.  \nEnter: ")
 time.sleep(1.5)

def mode():
 global NumberOfXItems, Themode
 for i in List:


Here you're appending an item and then the number of times that the item 
occurs:



 NumberOfXItems.append(i)
 NumberOfXItems.append(List.count(i))


Here you're getting the maximum entry, be it an item or the number of 
times an item occurs (see above). Have a look at the Counter class from 
the collections module:



 Themode = max(NumberOfXItems)
 print(Themode)



#-#   ~~The functions which need calling~~   #-#

# |
#|
#   \/

NOS()



--
https://mail.python.org/mailman/li

Re: Help please, why doesn't it show the next input?

2013-09-13 Thread John Gordon
In <364bcdb3-fdd5-4774-b7d2-040e2ccb4...@googlegroups.com> William Bryant 
 writes:

> Hello, I've done this so far but why doesn't the mode function work?

> def mode():
> global NumberOfXItems, Themode
> for i in List:
> NumberOfXItems.append(i)
> NumberOfXItems.append(List.count(i))
> Themode = max(NumberOfXItems)
> print(Themode)

As far as I can see, you're appending each of the user's numbers onto
NumberOfXItems, and you're also appending the number of times each number
occurs.

So, if the user had entered these numbers:

5 9 9 9 15 100 100

NumberOfXItems would end up looking like this:

5 1 9 3 9 3 9 3 15 1 100 2 100 2

The max is 100, but 9 is the most often-occuring number.

Also, since NumberOfXItems mixes user input and the counts of that input,
you risk getting a max that the user didn't even enter.  For example if the
user entered these numbers:

1 1 1 1 1 1 2 3

NumberOfXItems would end up looking like this:

1 6 1 6 1 6 1 6 1 6 1 6 2 1 3 1

The max is 6, which is a count, not user input.

mode would be much better written like this:

  def mode(mylist):

  max_occurrences = 0
  themode = None

  for i in mylist:
  thecount = mylist.count(i)
  if thecount > max_occurrences:
  max_occurrences = thecount
  themode = i

  print(themode)

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: Help please, why doesn't it show the next input?

2013-09-13 Thread William Bryant
On Thursday, September 12, 2013 9:39:33 PM UTC+12, Oscar Benjamin wrote:
> On 12 September 2013 07:04, William Bryant  wrote:
> 
> > Thanks everyone for helping but I did listen to you :3 Sorry. This is my 
> > code, it works, I know it's not the best way to do it and it's the long way 
> > round but it is one of my first programs ever and I'm happy with it:
> 
> 
> 
> Hi William, I'm glad you've solved your initial problem and I just
> 
> wanted to make a couple of comments about how your program could be
> 
> simplified or improved. The comments are below.
> 

Hello, I've done this so far but why doesn't the mode function work?

'''#*'''
#* Name:Mode-Median-Mean Calculator   *#
#**#
#* Purpose: To calculate the mode, median and mean of a list of numbers   *#
#*  and the mode of a list of strings because that is what we are *#
#*  learning in math atm in school :P *#
#**#
#* Author:  William Bryant*#
#**#
#* Created: 11/09/2013*#
#**#
#* Copyright:   (c) William 2013  *#
#**#
#* Licence: IDK :3*#
'''**'''




#-#   ~~Import things I am using~~   #-#

# |
#|
#   \/

import time
import itertools



#-#~~Variables that I am using, including the list.~~#-#

# |
#|
#   \/

List = []
NumberOfXItems = []
Themode = []

#-#   ~~Functions that I am using.~~ #-#

# |
#|
#   \/

def HMNs():
global TheStr, user_inputHMNs, List_input, List
user_inputHMNs = input("You picked string. This program cannot calculate 
the mean or median, but it can calculate the mode. :D  How many strings are you 
using in your list? (Can not be a decimal number)  \nEnter:  ")
user_inputHMNs
time.sleep(1.5)
TheStr = int(user_inputHMNs)
for i in range(TheStr):
List_input = input("Enter your strings. (One in each input field):  ")
List.append(List_input)
print("Your list -> ", List)
if List.count == int(user_inputHMNs):
break
mode()

def HMNn():
global TheNum, user_inputHMNn, List_input, List
user_inputHMNn = input("You picked number. :D How many numbers are you 
using in your list? (Can not be a decimal number) \nEnter:  ")
user_inputHMNn
time.sleep(1.5)
TheNum = int(user_inputHMNn)
for i in range(TheNum):
List_input = input("Enter your numbers. (One in each input field):  ")
List_input = int(List_input)
List.append(List_input)
print("Your list -> ", List)
if List.count == int(user_inputHMNn):
break
mode()
def NOS():
while True: # Loops forever (until the break)
answer = input("Does your list contain a number or a string?  \nEnter: 
")
answer = answer.lower()
if answer in ("string", "str", "s"):
HMNs()
break
elif answer in ("number", "num", "n", "int"):
HMNn()
break
elif answer in ("quit", "q"):
break  # Exits the while loop
else:
print("You did not enter a valid field, :P Sorry.  \nEnter: ")
time.sleep(1.5)

def mode():
global NumberOfXItems, Themode
for i in List:
NumberOfXItems.append(i)
NumberOfXItems.append(List.count(i))
Themode = max(NumberOfXItems)
print(Themode)



#-#   ~~The functions which need calling~~   #-#

# |
#|
#   \/

NOS()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help please, why doesn't it show the next input?

2013-09-12 Thread Oscar Benjamin
On 12 September 2013 07:04, William Bryant  wrote:
> Thanks everyone for helping but I did listen to you :3 Sorry. This is my 
> code, it works, I know it's not the best way to do it and it's the long way 
> round but it is one of my first programs ever and I'm happy with it:

Hi William, I'm glad you've solved your initial problem and I just
wanted to make a couple of comments about how your program could be
simplified or improved. The comments are below.

>
> '''#*'''
> #* Name:Mode-Median-Mean Calculator   
> *#
> #*
> *#
> #* Purpose: To calculate the mode, median and mean of a list of numbers   
> *#
> #*  and the mode of a list of strings because that is what we are 
> *#
> #*  learning in math atm in school :P 
> *#
> #*
> *#
> #* Author:  William Bryant
> *#
> #*
> *#
> #* Created: 11/09/2013
> *#
> #*
> *#
> #* Copyright:   (c) William 2013  
> *#
> #*
> *#
> #* Licence: IDK :3
> *#
> '''**'''
>
>
>
>
> #-#   ~~Import things I am using~~   
> #-#
>
> # |
> #|
> #   \/
>
> import time
> import itertools
>
>
>
> #-#~~Variables that I am using, including the list.~~
> #-#
>
> # |
> #|
> #   \/
>
> num_or_string = None
> amount_numbers = []
> List = []
> prompt = "Does your list contain, a number or a string?  \nEnter:  "
> user_inputHMNn = None
> user_inputHMNs = None

Of the declarations above only List and prompt are needed. Actually
though I wouldn't use either of those. List should really be a local
variable inside the functions below. And it would be better to write
prompt inline e.g.:

answer = input("Does your list contain, a number or a string?  \nEnter:  ")

That makes it easier to understand what's happening when you look at
the code. So I would remove all of those variable declarations. In
some other programming languages there are reasons to use declarations
like those above but not in Python.

>
> #-#   ~~Functions that I am using.~~ 
> #-#
>
> # |
> #|
> #   \/
>
> user_inputNOS = input(prompt)
> user_inputNOS
> time.sleep(1.5)
>
> def NOS():
> if user_inputNOS == "String" or user_inputNOS == "string" or 
> user_inputNOS == "STRING" or user_inputNOS == "s" or user_inputNOS == "S" or 
> user_inputNOS == "str":
> HMNs()
> elif user_inputNOS == "Number" or user_inputNOS == "number" or 
> user_inputNOS == "NUMBER" or user_inputNOS == "N" or user_inputNOS == "N" or 
> user_inputNOS == "int" or user_inputNOS == "num":
> HMNn()
> else:
> global user_inputNOS2
> global prompt
> prompt = "You did not enter a valid field, :P Sorry.  \nEnter:  "
> user_inputNOS2 = input(prompt)
> user_inputNOS2
> time.sleep(1.5)
> NOS2()
>
> def NOS2():
> if user_inputNOS2 == "String" or user_inputNOS2 == "string" or 
> user_inputNOS2 == "STRING" or user_inputNOS2 == "s" or user_inputNOS2 == "S" 
> or user_inputNOS2 == "str":
> HMNs()
> elif user_inputNOS2 == "Number" or user_inputNOS2 == "number" or 
> user_inputNOS2 == "NUMBER" or user_inputNOS2 == "N" or user_inputNOS2 == "N" 
> or user_inputNOS2 == "int" or user_inputNOS2 == "num":
> HMNn()
> else:
> global prompt
> prompt = "You did not enter a valid field, :P Sorry.  \nEnter:  "
> user_inputNOS2
> time.sleep(1.5)
> NOS2()

The functions above are almost identical. The main difference is just
that NOS2() doesn't call input() which I assume is accidental. So you
could simplify this by only having one function NOS() and having it
call itself rather than NOS2() at the end. Then it would look like:

def NOS():
# code here ...
NOS()

However this is not a common way to use recursive function calls. What
this really does is repeat something forever in a loop. The common way
to do this is to use a for-loop or a while-loop. For example you can
get the same effect with:

while True:  # Loops forever (until the break)
answer = input("Does your list contain, a number or a string?  \nEnter: ")
answer = answer.lower()
if answe

Re: Help please, why doesn't it show the next input?

2013-09-11 Thread William Bryant
Thanks everyone for helping but I did listen to you :3 Sorry. This is my code, 
it works, I know it's not the best way to do it and it's the long way round but 
it is one of my first programs ever and I'm happy with it:

'''#*'''
#* Name:Mode-Median-Mean Calculator   *#
#**#
#* Purpose: To calculate the mode, median and mean of a list of numbers   *#
#*  and the mode of a list of strings because that is what we are *#
#*  learning in math atm in school :P *#
#**#
#* Author:  William Bryant*#
#**#
#* Created: 11/09/2013*#
#**#
#* Copyright:   (c) William 2013  *#
#**#
#* Licence: IDK :3*#
'''**'''




#-#   ~~Import things I am using~~   #-#

# |
#|
#   \/

import time
import itertools



#-#~~Variables that I am using, including the list.~~#-#

# |
#|
#   \/

num_or_string = None
amount_numbers = []
List = []
prompt = "Does your list contain, a number or a string?  \nEnter:  "
user_inputHMNn = None
user_inputHMNs = None

#-#   ~~Functions that I am using.~~ #-#

# |
#|
#   \/

user_inputNOS = input(prompt)
user_inputNOS
time.sleep(1.5)

def NOS():
if user_inputNOS == "String" or user_inputNOS == "string" or user_inputNOS 
== "STRING" or user_inputNOS == "s" or user_inputNOS == "S" or user_inputNOS == 
"str":
HMNs()
elif user_inputNOS == "Number" or user_inputNOS == "number" or 
user_inputNOS == "NUMBER" or user_inputNOS == "N" or user_inputNOS == "N" or 
user_inputNOS == "int" or user_inputNOS == "num":
HMNn()
else:
global user_inputNOS2
global prompt
prompt = "You did not enter a valid field, :P Sorry.  \nEnter:  "
user_inputNOS2 = input(prompt)
user_inputNOS2
time.sleep(1.5)
NOS2()

def NOS2():
if user_inputNOS2 == "String" or user_inputNOS2 == "string" or 
user_inputNOS2 == "STRING" or user_inputNOS2 == "s" or user_inputNOS2 == "S" or 
user_inputNOS2 == "str":
HMNs()
elif user_inputNOS2 == "Number" or user_inputNOS2 == "number" or 
user_inputNOS2 == "NUMBER" or user_inputNOS2 == "N" or user_inputNOS2 == "N" or 
user_inputNOS2 == "int" or user_inputNOS2 == "num":
HMNn()
else:
global prompt
prompt = "You did not enter a valid field, :P Sorry.  \nEnter:  "
user_inputNOS2
time.sleep(1.5)
NOS2()

def HMNs():
global TheStr, user_inputHMNs, List_input
user_inputHMNs = input("You picked string. This program cannot calculate 
the mean or median, but it can calculate the mode. :D  How many strings are you 
using in your list? (Can not be a decimal number)  \nEnter:  ")
user_inputHMNs
time.sleep(1.5)
TheStr = int(user_inputHMNs)
for i in range(TheStr):
List_input = input("Enter your strings. (One in each input field):  ")
List.append(List_input)
print("Your list -> ", List)

def HMNn():
global TheNum, user_inputHMNn, List_input
user_inputHMNn = input("You picked number. :D How many numbers are you 
using in your list? (Can not be a decimal number) \nEnter:  ")
user_inputHMNn
time.sleep(1.5)
TheNum = int(user_inputHMNn)
for i in range(TheNum):
List_input = input("Enter your numbers. (One in each input field):  ")
List.append(List_input)
print("Your list -> ", List)


#-#   ~~The functions which need calling~~   #-#

# |
#|
#   \/

NOS()


Not done. I'll finish it today! :) Oh and thanks so much for helping, you guys 
are really nice :D Thanks a lot.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help please, why doesn't it show the next input?

2013-09-11 Thread Jugurtha Hadjar

On 09/12/2013 02:08 AM, Jugurtha Hadjar wrote:


Try this on your python prompt

mystring = "ThIs Is ThE wAy SoMe StUpId PeOpLe WrItE i DoN't KnOw WhY!"
mystring.lower()



This should return:

"You shouldn't treat people of stupid, but I feel your pain", or let's 
be more realistic:


"this is the way some stupid people write i don't know why!"


--
~Jugurtha Hadjar,
--
https://mail.python.org/mailman/listinfo/python-list


Re: Help please, why doesn't it show the next input?

2013-09-11 Thread Jugurtha Hadjar

On 09/11/2013 08:33 PM, William Bryant wrote:

@Jugurtha Hadjar
What does user_input.lower() mean/do?



Hello,

As did other people point out, it returns the lower case of a string. 
It's not user_input.lower(), it's any_string.lower()


For example:

Try this on your python prompt

mystring = "ThIs Is ThE wAy SoMe StUpId PeOpLe WrItE i DoN't KnOw WhY!"
mystring.lower()





--
~Jugurtha Hadjar,
--
https://mail.python.org/mailman/listinfo/python-list


Re: Help please, why doesn't it show the next input?

2013-09-11 Thread Terry Reedy

On 9/11/2013 3:31 PM, William Bryant wrote:


What is .lower() ?


The Python docs have a pretty good index that includes 'lower() (str 
method)'.  Learn to use it.


If you know that .lower is a str method,
>>> help(str.lower)
at interactive prompt prints a page. Learn to use help(ob) also.


--
Terry Jan Reedy

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


RE: Help please, why doesn't it show the next input?

2013-09-11 Thread Prasad, Ramit
William Bryant wrote:
> Sent: Wednesday, September 11, 2013 2:32 PM
> To: python-list@python.org
> Subject: Re: Help please, why doesn't it show the next input?
> 
> @Dave Angel
> 
> What is .lower() ?

Thanks for bottom posting and trimming, but you should
leave some content quoted for context. Otherwise
people will not what you are referring to.

You can find answers to questions like this in the API.
http://docs.python.org/2/library/stdtypes.html#str.lower

I would recommend taking time to get familiar with the
Athena interpreter. It can also answer questions like
this (but with less detail than the web API).

You can use dir() to find the attributes on any object.
help() will give you docstring for the attribute/class.

>>> 'A'.lower()
'a'
>>> help(''.lower)
Help on built-in function lower:

lower(...)
S.lower() -> string

Return a copy of the string S converted to lowercase.

>>> help(dir)
Help on built-in function dir in module __builtin__:
dir(...)
dir([object]) -> list of strings

If called without an argument, return the names in the current scope.
Else, return an alphabetized list of names comprising (some of) the 
attributes
of the given object, and of attributes reachable from it.
If the object supplies a method named __dir__, it will be used; otherwise
the default dir() logic is used and returns:
  for a module object: the module's attributes.
  for a class object:  its attributes, and recursively the attributes
of its bases.
  for any other object: its attributes, its class's attributes, and

recursively the attributes of its class's base classes.
>>> dir('')
['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', 
'__format__', '__ge__', '__getattribute__', '__getitem_\
_', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', 
'__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__\
', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', 
'__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclass\
hook__', '_formatter_field_name_split', '_formatter_parser', 'capitalize', 
'center', 'count', 'decode', 'encode', 'endswith', 'expan\
dtabs', 'find', 'format', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 
'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lo\
wer', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 
'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'starts\
with', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']

If you want to see all the relevant information you can use help()
on the class [e.g. help(str)]. I think help(class) will not show
functions that start with _ unless they are python magic dunder 
functions (e.g. __str__).



~Ramit



This email is confidential and subject to important disclaimers and conditions 
including on offers for the purchase or sale of securities, accuracy and 
completeness of information, viruses, confidentiality, legal privilege, and 
legal entity disclaimers, available at 
http://www.jpmorgan.com/pages/disclosures/email.  
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help please, why doesn't it show the next input?

2013-09-11 Thread Dave Angel
On 11/9/2013 15:31, William Bryant wrote:

> @Dave Angel
>
> What is .lower() ?
It is a method on the str class.

You could teach yourself.  At the interpreter prompt, type

 help("test response".lower)

Or on the web:

http://docs.python.org/2/library/stdtypes.html#str.lower

There are lots of other interesting methods in the str class, listed on
that section of that page.

-- 
DaveA


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


Re: Help please, why doesn't it show the next input?

2013-09-11 Thread John Gordon
In  William Bryant 
 writes:

> @Jugurtha Hadjar
> What does user_input.lower() mean/do?

String objects have a number of built-in functions, lower() being one of
them.  It returns a copy of the string with all uppercase letters converted
to lowercase.

Example:

>>> x = "Hello There"
>>> y = x.lower()
>>> print y
hello there

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


Re: Help please, why doesn't it show the next input?

2013-09-11 Thread William Bryant
@Dave Angel

What is .lower() ?
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   3   4   >