Re: [Tutor] python question

2019-08-18 Thread Steven D'Aprano
On Sun, Aug 18, 2019 at 12:35:52PM +0800, Thejal Ramesh wrote: > Hi, i have a question regarding this question. I'm not quite sure what the > question is asking. Ask your tutor. We can help you with learning Python the programming language, not graph theory. https://en.wikipedia.org/wiki/Graph_t

Re: [Tutor] python question

2019-08-18 Thread Alan Gauld via Tutor
On 18/08/2019 05:35, Thejal Ramesh wrote: > Hi, i have a question regarding this question. I'm not quite sure what the > question is asking. > Part A: Popular (1.5 Marks) > Write a function popular(graph list, n) that returns a list of people who > have at least n friends. Each person is identifi

Re: [Tutor] Python code

2019-08-01 Thread David Rock
maybe a copy/paste of your terminal session so we can see the text of the steps you are actually performing will give use some clues. — David > On Aug 1, 2019, at 18:22, David L Neil wrote: > > On 2/08/19 3:23 AM, Spencer Wannemacher wrote: >> I'm new to python and I was trying to perform a si

Re: [Tutor] Python code

2019-08-01 Thread David L Neil
On 2/08/19 3:23 AM, Spencer Wannemacher wrote: I'm new to python and I was trying to perform a simple one code. All that is included in the code is print(61). I save it as 61.py and change the directory before typing in python 61.py and I don't get an output. There is no error and the output i

Re: [Tutor] Python code

2019-08-01 Thread Cameron Simpson
On 01Aug2019 15:23, Spencer Wannemacher wrote: I'm new to python and I was trying to perform a simple one code. All that is included in the code is print(61). I save it as 61.py and change the directory before typing in python 61.py and I don't get an output. There is no error and the output i

Re: [Tutor] python idle file couldn't start

2019-07-24 Thread Flynn, Stephen (Life & Pensions)
What (precisely) did you type to "start python through idle"? Don't guess - cut and pasted EXACTLY what you type and what you see on screen. S. -Original Message- From: Tutor On Behalf Of siva Sent: 24 July 2019 08:57 To: tutor@python.org Subject: [Tutor] python idle file couldn't star

Re: [Tutor] Python Generator expressions

2019-07-23 Thread Steven D'Aprano
On Wed, Jul 24, 2019 at 11:26:26AM +1200, David L Neil wrote: > Clarifying the difference/similarity in appearance between a generator > expression and a tuple, it might help to think that it is the comma(s) > which make it a tuple! David makes an excellent point here. Except for the special ca

Re: [Tutor] Python Generator expressions

2019-07-23 Thread Steven D'Aprano
On Tue, Jul 23, 2019 at 10:36:01PM +0530, Animesh Bhadra wrote: > Hi All, > > Need one help in understanding generator expression/comprehensions. > > This is my sample code. Lots of missing spaces in your code! Don't forget to hit the space bar between words :-) Also missing indentation, which

Re: [Tutor] Python Generator expressions

2019-07-23 Thread Mats Wichmann
On 7/23/19 11:06 AM, Animesh Bhadra wrote: > Hi All, > > Need one help in understanding generator expression/comprehensions. > > This is my sample code. > > # This code creates a generator and not a tuple comprehensions. > my_square =(num *num fornum inrange(11)) > print(my_square) # at 0x7f3c8

Re: [Tutor] Python Generator expressions

2019-07-23 Thread David L Neil
Hi Animesh, Unfortunately the list server/email has removed the formatting from your sample, but no matter... On 24/07/19 5:06 AM, Animesh Bhadra wrote: # This code creates a generator and not a tuple comprehensions. my_square =(num *num fornum inrange(11)) print(my_square) # at 0x7f3c838c0c

Re: [Tutor] Python Imported Code

2019-07-20 Thread Albert-Jan Roskam
On 25 Jun 2019 15:50, stephen.m.sm...@comcast.net wrote: Introduction: I have written a 'program' that does some reasonable screen scraping off of a specific website. The program has gotten too large so I have tried to segment it into logical pieces (tkinter logic as a start) but I am having pr

Re: [Tutor] Python 3.7 Grids

2019-06-29 Thread boB Stepp
On Sat, Jun 29, 2019 at 2:02 AM David Merrick wrote: > > Hi Looking for a way to use the determine the position of a card in a grid > using the mouse click event in Python. Code is attached. There are no > viruses. > > Unfortunately using Tinkter grids / frames can't determine between the two > de

Re: [Tutor] [Python-Help] Writing hello world

2019-06-29 Thread Bob Gailer
On Jun 28, 2019 9:26 AM, "Erastus muriithi" wrote: > > Iam a student..iam interested in learning python,,I don't know how to study this python.kindly help me how to go about it..Thankyou First make sure you have python installed on your computer. If you need help with that let us know what kind o

Re: [Tutor] Python 3.7 Grids

2019-06-29 Thread Bob Gailer
On Jun 29, 2019 3:01 AM, "David Merrick" wrote: > > Hi Looking for a way to use the determine the position of a card in a grid > using the mouse click event in Python. Code is attached. Unfortunately this list does not forward attachments. Either give us a link to the code or even better if it's

Re: [Tutor] Python and DB

2019-06-27 Thread Alan Gauld via Tutor
On 27/06/2019 22:20, Brave Heart via Tutor wrote: > I would like python to write to DB so I can from DB write on a webpage with > PHP... Yes, that's easy enough. Python supports access to many databases, do you have one in mind? If not the SQLite module that comes in the standard library is prob

Re: [Tutor] Python and DB

2019-06-27 Thread Cameron Simpson
On 27Jun2019 23:20, Brave Heart wrote: I have a little RSS program , I current the out are basically outputted on my screen, but I would like python to write to DB so I can from DB write on a webpage with PHP... Kinda like I want to run a news website .. See the "sqlite3" module with ships

Re: [Tutor] Python and DB

2019-06-27 Thread Mats Wichmann
On 6/27/19 3:20 PM, Brave Heart via Tutor wrote: > I have a little RSS program , I current the out are basically outputted on my > screen, but I would like python to write to DB so I can from DB write on a > webpage with PHP... > > Kinda like I want to run a news website .. There doesn't seem

Re: [Tutor] Python Imported Code

2019-06-25 Thread Alan Gauld via Tutor
On 25/06/2019 14:50, stephen.m.sm...@comcast.net wrote: > using global, but that fails. I also can't seem to use arguments because the > module that tkinter fires up with this command: > > self.process_button = tk.Button(master, text='Process Request', \ >

Re: [Tutor] python

2019-06-25 Thread Bob Gailer
On Jun 25, 2019 8:52 AM, "Shaon Debnath" wrote: > > I just wanted to know all about map() function in python. See https://www.geeksforgeeks.org/python-map-function/. If after reading that you still have questions please come back and ask them. Bob Gailer

Re: [Tutor] Python type annotation question

2019-06-24 Thread Mats Wichmann
On 6/24/19 12:48 PM, Arup Rakshit wrote: > I am little experimenting with Python type annotation today. I wrote a simple > class as below: > from datetime import date class Person: > ... dob: date > ... def __init__(self, dob): > ... self.dob = dob > ... Person

Re: [Tutor] Python printing parentheses and quotes

2019-06-11 Thread Sai Allu
From: Cameron Simpson Sent: Monday, June 10, 2019 5:34 PM To: Sai Allu Cc: Mats Wichmann; tutor@python.org; Deepak Dixit Subject: Re: [Tutor] Python printing parentheses and quotes On 10Jun2019 19:04, Sai Allu wrote: >Actually I'm pretty sure what happened was that the "#! usr/bin/python&

Re: [Tutor] Python printing parentheses and quotes

2019-06-10 Thread Cameron Simpson
On 10Jun2019 19:04, Sai Allu wrote: Actually I'm pretty sure what happened was that the "#! usr/bin/python" was in a module that was being imported. So the Python interpreter cached it or somehow crashed randomly, which meant that the print was working as a keyword instead of a function. But

Re: [Tutor] Python printing parentheses and quotes

2019-06-10 Thread Sai Allu
hat "#! usr/bin/python" line and then rewrote the print statements, it went back to working normally. Thank you for the help though! Sai Allu From: Sai Allu Sent: Monday, June 10, 2019 11:53 AM To: Mats Wichmann; tutor@python.org; Deepak Dixit Subject: Re

Re: [Tutor] Python printing parentheses and quotes

2019-06-10 Thread Sai Allu
: Sai Allu; tutor@python.org Subject: Re: [Tutor] Python printing parentheses and quotes On 6/10/19 10:50 AM, Sai Allu wrote: > Hello! > > I was just wondering if anybody encountered an issue where the Python > interpreter was changing how it interprets print statements. So I'm usin

Re: [Tutor] Python printing parentheses and quotes

2019-06-10 Thread Alan Gauld via Tutor
On 10/06/2019 17:50, Sai Allu wrote: > Basically what happened was that I had a few lines in the script like this > ip = "10.41.17.237" > print(" Welcome to Squid Monitoring for ", ip) > print("") > > and the output was like this > > (" Welcome to Squid Monitoring for 10.41.17.

Re: [Tutor] Python printing parentheses and quotes

2019-06-10 Thread Mats Wichmann
On 6/10/19 10:50 AM, Sai Allu wrote: > Hello! > > I was just wondering if anybody encountered an issue where the Python > interpreter was changing how it interprets print statements. So I'm using > default Python on Mac OSX (2.7.10 I'm pretty sure) and running with the > "python script.py" comm

Re: [Tutor] Python Django Query

2019-04-02 Thread nitin chandra
Thanks Cameron, Just got lucky yesterday and found a resource at my end to help me out. Thank you On Tue, 2 Apr 2019 at 04:31, Cameron Simpson wrote: > > On 29Mar2019 21:18, nitin chandra wrote: > >Hi Everyone, > >I need some guidance / corrections to my code. > >I hosted a demo site on python

Re: [Tutor] Python Django Query

2019-04-01 Thread Cameron Simpson
On 29Mar2019 21:18, nitin chandra wrote: Hi Everyone, I need some guidance / corrections to my code. I hosted a demo site on pythonanywhere.com and to test the initial pages I wrote some test code. [...] Hi Nitin, I looks like nobody has replied; this probably means that nobody has the requi

Re: [Tutor] Python Regular Expressions (Re.sub) Function

2019-03-04 Thread Alan Gauld via Tutor
On 04/03/2019 08:04, Edward Kanja wrote: > ... Unfortunately after i extract the data > my output has too much of square brackets and by so doing the output cant > be well exported in a csv file. I can't see the data so can't be definitive but the number of square brackets shouldn't affect a CSV

Re: [Tutor] Python Regular Expressions (Re.sub) Function

2019-03-04 Thread Steven D'Aprano
Hi Edward, and welcome. Please remember that we're volunteers, doing this for free. Unless your problem is really interesting, you're not likely to get people volunteering to spend a long time slogging through multiple attachments, screenshots, at least five seperate attempts, etc. By the way,

Re: [Tutor] Python Websocket Server

2019-02-14 Thread Mats Wichmann
On 2/14/19 9:44 AM, Simon Connah wrote: > Hi, > > I was wondering what the best practice for writing web socket servers in > Python was in 2019? I found an old example on the web which used the > tornado library but that was talking about Chrome 22 as the client which > is ancient now so I'm not s

Re: [Tutor] Python Websocket Server

2019-02-14 Thread Alan Gauld via Tutor
On 14/02/2019 16:44, Simon Connah wrote: > I was wondering what the best practice for writing web socket servers in > Python was in 2019? I can't answer that directly since I've never used web sockets in Python (and only played with them in Java). But... > I found an old example on the web whi

Re: [Tutor] python-files

2019-01-27 Thread Alan Gauld via Tutor
On 27/01/2019 14:57, Asad wrote: > print("first:", args.first) > print("second:", args.second) > > When I execute the script it gives error : > > python python_json_20001_oratest_v1.py "file1" > ('first:', 'file1') > ('second:', None) Note that the second file is None. > Traceback (most recent

Re: [Tutor] python-files

2019-01-27 Thread Peter Otten
Asad wrote: > Hi All , > > I tried the following code : > > parser = argparse.ArgumentParser() > parser.add_argument("first") > parser.add_argument("second", nargs="?") > args = parser.parse_args() > print("first:", args.first) > > print("second:", args.second) > > When I execute th

Re: [Tutor] python-files

2019-01-27 Thread Asad
t [second] > > positional arguments: > first > second > > optional arguments: > -h, --help show this help message and exit > > $ ./test.py ONE > first: ONE > second: None > > $ ./test.py ONE TWO > first: ONE > second: TWO > > $ ./test.py ONE TWO THRE

Re: [Tutor] python - files

2019-01-27 Thread Cameron Simpson
On 27Jan2019 10:30, Peter Otten <__pete...@web.de> wrote: Cameron Simpson wrote: Mats has mentioned the modules getopt and argparse etc. These are primarily aimed at option parsing ("-v", "-o foo"). Your situation occurs _after_ the option parsing (in your case, there are no options). Not argp

Re: [Tutor] python - files

2019-01-27 Thread Peter Otten
Cameron Simpson wrote: > Mats has mentioned the modules getopt and argparse etc. These are > primarily aimed at option parsing ("-v", "-o foo"). Your situation > occurs _after_ the option parsing (in your case, there are no options). Not argparse. The main advantage over optparse is its handling

Re: [Tutor] python - files

2019-01-26 Thread Cameron Simpson
Mats has mentioned the modules getopt and argparse etc. These are primarily aimed at option parsing ("-v", "-o foo"). Your situation occurs _after_ the option parsing (in your case, there are no options). Alan has talked about explicitly checking the length of sys.argv, much as you are doing,

Re: [Tutor] python - files

2019-01-26 Thread Mats Wichmann
On 1/26/19 1:20 AM, Asad wrote: > Hi All , > >I would like to know how do I make and option file as an argument on > command propmnt in python I don't know your context for asking this question. Alan has already explained what you need to do for your issue, and whatever your needs it is

Re: [Tutor] python - files

2019-01-26 Thread Alan Gauld via Tutor
On 26/01/2019 08:20, Asad wrote: >At present I using : > > if len(sys.argv) == 3: > first = sys.argv[1] > second = sys.argv[2] > else: > print "enter the second argument" > It works well for the following command : > python test.py file1 file2 Correct because it tests if the

Re: [Tutor] Python installtion

2019-01-13 Thread Stephen Nelson-Smith
Hi, On Mon, Jan 7, 2019 at 11:11 AM mousumi sahu wrote: > > Dear Sir, > I am trying to install python 2.7.10 on HPC. Python 2.6 has already been > install on root. I do not have root authority. Please suggest me how can I > do this. Sorry - I replied to you directly, by accident. Take 2, with r

Re: [Tutor] Python installtion

2019-01-07 Thread Oscar Benjamin
On Mon, 7 Jan 2019 at 11:10, mousumi sahu wrote: > > Dear Sir, > I am trying to install python 2.7.10 on HPC. Python 2.6 has already been > install on root. I do not have root authority. Please suggest me how can I > do this. Does HPC stand for High-Performance Computing? Are you trying to set up

Re: [Tutor] Python installtion

2019-01-07 Thread Steven D'Aprano
On Mon, Jan 07, 2019 at 03:36:01PM +0530, mousumi sahu wrote: > Dear Sir, > I am trying to install python 2.7.10 on HPC. Python 2.6 has already been > install on root. I do not have root authority. Please suggest me how can I > do this. What's HPC? If you don't have root permission, do you have p

Re: [Tutor] Python

2018-12-20 Thread Steven D'Aprano
On Thu, Dec 20, 2018 at 10:49:25AM -0500, Mary Sauerland wrote: > I want to get rid of words that are less than three characters > f1_name = "/Users/marysauerland/Documents/file1.txt" > #the opinions > f2_name = "/Users/marysauerland/Documents/file2.txt" > #the constitution Better than comments

Re: [Tutor] Python

2018-12-20 Thread Avi Gross
Mary, Mary, It is often best to develop and test small parts of the project where you can easily play with it, then move it into more complex configurations like a function body Here is your code: def read_words(words_file): return [word.upper() for line in open(words_file, 'r') for word in

Re: [Tutor] Python

2018-12-20 Thread Mats Wichmann
On 12/20/18 8:49 AM, Mary Sauerland wrote: > Hi, > > I want to get rid of words that are less than three characters but I keep > getting errors. I tried multiple ways but keep getting errors. Just a quick note or two: > > Here is my code: > > f1_name = "/Users/marysauerland/Documents/file1.t

Re: [Tutor] Python

2018-12-20 Thread Bob Gailer
On Dec 20, 2018 12:17 PM, "Mary Sauerland" wrote: > > Hi, > > I want to get rid of words that are less than three characters but I keep getting errors. I tried multiple ways but keep getting errors. Hi Mary welcome to the tutor list. We love to help. We are a few volunteers. It is very difficult

Re: [Tutor] Python function

2018-12-14 Thread Avi Gross
@python.org Subject: Re: [Tutor] Python function On 13/12/2018 17:21, Sammy Lee wrote: > How do I create a python function that opens a CSV file and determines > how many columns of data are in the file? The CSV files have been > randomly generated from https://www.mockaroo.com/

Re: [Tutor] Python function

2018-12-13 Thread Alan Gauld via Tutor
On 13/12/2018 17:21, Sammy Lee wrote: > How do I create a python function that opens a CSV file and determines how > many columns > of data are in the file? The CSV files have been randomly generated from > https://www.mockaroo.com/ > > def csv_column_count(openfile): You will find a bunch of s

Re: [Tutor] Python function

2018-12-13 Thread Bob Gailer
On Dec 13, 2018 1:55 PM, "Sammy Lee" wrote: > > How do I create a python function that opens a CSV file and determines how many columns > of data are in the file? The CSV files have been randomly generated from https://www.mockaroo.com/ > > def csv_column_count(openfile): Same comments as I made

Re: [Tutor] Python script errors

2018-12-12 Thread Steven D'Aprano
On Wed, Dec 12, 2018 at 06:57:09AM -0600, Ravi Kumar wrote: > I know this occurs when the api response is nulls but how do I handle this? if response is None: handle None case else: handle non-None case -- Steve ___ Tutor maillist - Tutor@

Re: [Tutor] Python script errors

2018-12-12 Thread Peter Otten
Ravi Kumar wrote: > Hi, > > I have developed a python script to get api calls for meraki > clientlogevents Thanks for all the help previously I am facing few errors > such as > > Json_string=r.json() > > raw_decode > raise JSONDecodeError("Expecting value", s, err.value) from None > json.d

Re: [Tutor] Python script errors

2018-12-12 Thread Alan Gauld via Tutor
On 12/12/2018 12:57, Ravi Kumar wrote: > '{0:20} {1:30} {2:16} {3:18} {4:10} {5:11} '.format( > deviceserial, type, macaddress,occurredAt, details)) > TypeError: unsupported format string passed to NoneType.__format__ You have 6 format holders in your string but you only pass 5 values

Re: [Tutor] [Python 3] Threads status, join() and Semaphore queue

2018-11-24 Thread Cameron Simpson
On 24Nov2018 16:08, Dimitar Ivanov wrote: Your explanation definitely clears up quite a bit of my misunderstanding, thank you for that! There was a reason why I shy away from using Queue, but for the life of me I can't remember right now what that reason was. I will have to modify my code usin

Re: [Tutor] [Python 3] Threads status, join() and Semaphore queue

2018-11-24 Thread Dimitar Ivanov
Hi Cameron, Massive apologies for the delayed answer! Your explanation definitely clears up quite a bit of my misunderstanding, thank you for that! There was a reason why I shy away from using Queue, but for the life of me I can't remember right now what that reason was. I will have to modify my

Re: [Tutor] [Python 3] Threads status, join() and Semaphore queue

2018-11-19 Thread Cameron Simpson
On 19Nov2018 23:52, Dimitar Ivanov wrote: I'm having a hard time getting my head around threads so I was hoping someone who has better understanding of their underlying functionality could lend me a helping hand, in particular how threads work with each other when using thread.join() and Semapho

Re: [Tutor] Python 3.6 update?

2018-10-27 Thread Jim
On 10/25/18 5:30 PM, Mats Wichmann wrote: On 10/25/2018 03:07 PM, Jim wrote: Mint 18.1 Default python3 = 3.5 Python 3.6 installed for use by a virtual environment. Update manager just informed me of an update for python 3.6 to 3.6.7-1. When I started to install it, I got a dialog saying: thi

Re: [Tutor] Python Help

2018-10-26 Thread Alan Gauld via Tutor
On 26/10/2018 18:20, Adam Eyring wrote: > beef = (beefmeals * 15.95) Note that the parens here are completely redundant. They don't break anything but neither do they contribute anything. WE already have LISP(*) for those who love parens, no need for (so many of) them in Python (*)Lots of Irrel

Re: [Tutor] Python Help

2018-10-26 Thread Adam Eyring
On Fri, Oct 26, 2018 at 3:03 PM Bob Gailer wrote: > On Oct 26, 2018 1:20 PM, "Adam Eyring" wrote: > > > > Try this cleaned up version with colons in the right places, dollar > signs removed, and other corrections: > > Does it do what you want? > > > beefmeals=int(input("Enter number of beef meal

Re: [Tutor] Python Help

2018-10-26 Thread Adam Eyring
Try this cleaned up version with colons in the right places, dollar signs removed, and other corrections: beefmeals=int(input("Enter number of beef meals: ")) shitmeals=int(input("Enter number of vegan meals: ")) party = beefmeals + shitmeals print("Total meals", party) a = 0 b = 0 c = 0 if party

Re: [Tutor] Python Help

2018-10-26 Thread Bob Gailer
On Oct 26, 2018 1:20 PM, "Adam Eyring" wrote: > > Try this cleaned up version with colons in the right places, dollar signs removed, and other corrections: Does it do what you want? > beefmeals=int(input("Enter number of beef meals: ")) > shitmeals=int(input("Enter number of vegan meals: ")) > p

Re: [Tutor] Python Help

2018-10-26 Thread Bob Gailer
On Oct 26, 2018 6:11 AM, "Ben Placella" wrote: > > I need to write code that runs a cost calculating program with many > different variables and I honestly don't understand it Could you be more specific? What exactly don't you understand, or even better what do you understand? my code is: How

Re: [Tutor] Python Help

2018-10-26 Thread Alan Gauld via Tutor
On 25/10/2018 23:14, Ben Placella wrote: Please always post code in plain text not HTML or Rich text. Otherwise we lose all the formatting which is important in Python. > beefmeals=int(input("Enter number of beef meals: ")) > shitmeals=int(input("Enter number of vegan meals: ")) > party=beefmeals

Re: [Tutor] Python Help (shits killing me)

2018-10-26 Thread Steven D'Aprano
On Thu, Oct 25, 2018 at 06:13:31PM -0400, Ben Placella wrote: > So I have to make a fibonacci sequence, and I'm not sure what is wrong with > my code [...] > attached is a photo of what the output SHOULD look like No it isn't. For security (anti-spam, anti-virus) reasons, this mailing list delet

Re: [Tutor] Python Help

2018-10-26 Thread Steven D'Aprano
On Thu, Oct 25, 2018 at 06:14:41PM -0400, Ben Placella wrote: > I need to write code that runs a cost calculating program with many > different variables and I honestly don't understand it, my code is: > beefmeals=int(input("Enter number of beef meals: ")) > shitmeals=int(input("Enter number of ve

Re: [Tutor] Python Help (shits killing me)

2018-10-26 Thread Alan Gauld via Tutor
Plain text is preferred for code since otherwise the mail system removes all indentation making the code hard to understand. On 25/10/2018 23:13, Ben Placella wrote: > So I have to make a fibonacci sequence, and I'm not sure what is wrong with > my code > #This program illustrates the fibonacci se

Re: [Tutor] Python Help (shits killing me)

2018-10-26 Thread Andrew Van Valkenburg
nth = n1 + n I don't see where n is defined anywhere. Should be n2? On Fri, Oct 26, 2018 at 6:09 AM Ben Placella wrote: > So I have to make a fibonacci sequence, and I'm not sure what is wrong with > my code > #This program illustrates the fibonacci sequence > nterms=int(input("Please enter ho

Re: [Tutor] Python 3.6 update?

2018-10-25 Thread Mats Wichmann
On 10/25/2018 03:07 PM, Jim wrote: > Mint 18.1 > Default python3 = 3.5 > Python 3.6 installed for use by a virtual environment. > > > > Update manager just informed me of an update for python 3.6 to 3.6.7-1. > When I started to install it, I got a dialog saying: > > this upgrade will trigger ad

Re: [Tutor] python game error

2018-10-15 Thread Peter Otten
Alan Gauld via Tutor wrote: > On 15/10/18 08:57, Peter Otten wrote: > >> By the way, you do not need a map (dict) at all to implement a game like >> this, you may return the next scene directly. A sketch: >> >> class Bridge: >> def enter(self): >> ... >> action = ... >>

Re: [Tutor] python game error

2018-10-15 Thread Alan Gauld via Tutor
On 15/10/18 08:57, Peter Otten wrote: > By the way, you do not need a map (dict) at all to implement a game like > this, you may return the next scene directly. A sketch: > > class Bridge: > def enter(self): > ... > action = ... > if action == "jump off the bridge": >

Re: [Tutor] python game error

2018-10-15 Thread Peter Otten
bob gailer wrote: > Python coding "trick"1 > when I build a map I omit the () after the class e.g. 'death' = Death, > ... and apply them to the item retrieved from the map. > > use a decorator to build the map dictionary: > > # the decorator function: > def add_to_ma

Re: [Tutor] python game error

2018-10-14 Thread bob gailer
More comments on code: guess = raw_input("[pod #]> ")     if int(guess) != good_pod: If user enters something that will not convert to integer an exception will be raised. For example >>> int('a') Traceback (most recent call last):   File "", line 1, in ValueError: invalid literal

Re: [Tutor] python game error

2018-10-14 Thread bob gailer
On 10/14/2018 1:42 PM, Mats Wichmann wrote: Hint here: don't use 'map' as your own variable name, since it's a built-in function. Absolutely, I am always warning others about this gotcha. In this case map is local to add_to_map so it does not affect then global namespace. The reason I used it

Re: [Tutor] python game error

2018-10-14 Thread Mats Wichmann
On 10/14/2018 10:08 AM, bob gailer wrote: > Python coding "trick"1  > when I build a map I omit the () after the class e.g. 'death' = Death, > ... and apply them to the item retrieved from the map. > > use a decorator to build the map dictionary: > > # the decorator fun

Re: [Tutor] python game error

2018-10-14 Thread bob gailer
More comments: User Friendly? I hope this game is not intended for actual use. No one will be able to guess the correct actions in a reasonable time. or 3 digit random code given 10 tries for any one code. I for one would give up pretty quickly. The original colossal

Re: [Tutor] python game error

2018-10-14 Thread bob gailer
On 10/13/2018 4:25 AM, Mariam Haji wrote: ... Your problem intrigued me enough to spend some time "fixing" your program so it will compile with no errors and run at least the initial case where I entered "shoot!" Here are the problems I found: (line numbers refer to your original code) - spell

Re: [Tutor] python game error

2018-10-13 Thread Bob Gailer
suggestions: 1-Use triple-quoted strings: print """take the short-cut!""' 2 - make the program much simpler to start with. The usual approach to developing programs like this is to start simple get the simple things working right then add more complicated scene descriptions. Even better: separa

Re: [Tutor] python game error

2018-10-13 Thread Peter Otten
Mariam Haji wrote: > Hi guys, > > I am still on the learn python the hard way. > I built the below on python 2.7 and my OS is windows 7. > > I am getting this error: > Traceback (most recent call last): > File "ex43.py", line 205, in > a_game.play() > File "ex43.py", line 21, in play >

Re: [Tutor] python game error

2018-10-13 Thread Steven D'Aprano
On Sat, Oct 13, 2018 at 11:25:20AM +0300, Mariam Haji wrote: > Hi guys, > > I am still on the learn python the hard way. > I built the below on python 2.7 and my OS is windows 7. > > I am getting this error: > Traceback (most recent call last): > File "ex43.py", line 205, in > a_game.play(

Re: [Tutor] Python

2018-10-12 Thread Alan Gauld via Tutor
On 12/10/18 02:41, Tyler Travis via Tutor wrote: > I used a shortcut by import the statistics function. ... > it does not print the expected output, Did you by any chance include your code as an attachment? If so this mail server will strip it out as a security risk. Please post any code in the

Re: [Tutor] Python

2018-10-12 Thread Steven D'Aprano
On Thu, Oct 11, 2018 at 08:41:08PM -0500, Tyler Travis via Tutor wrote: > I fully understand the concept of what I am trying to do I'm very glad that at least one of us understands what you are trying to do, but I have no clue what it is. > and I know > that you can type out the algorithms t

Re: [Tutor] Python

2018-10-12 Thread Mark Lawrence
On 12/10/18 02:41, Tyler Travis via Tutor wrote: I fully understand the concept of what I am trying to do and I know that you can type out the algorithms to find mean, median, and mode but I used a shortcut by import the statistics function. Which yields the same results and the program passes

Re: [Tutor] Python programming help!

2018-09-23 Thread V E G E T A L
Wow, didn't know attachments didn't work. I had posted my screenshot as an attachment, never expected you to read my mind. I solved the problem, it was a spelling mistake (I know, I'm stupid). Thank a lot though! Στις Κυρ, 23 Σεπ 2018 - 16:25 ο χρήστης Bob Gailer έγραψε: > On Sep 23, 2018 3:33 A

Re: [Tutor] Python programming help!

2018-09-23 Thread Carlton Banks
Without having Seen the code, use og statements.. but please provide is the code... søn. 23. sep. 2018 15.26 skrev Bob Gailer : > On Sep 23, 2018 3:33 AM, "V E G E T A L" > wrote: > > > > Hello folks! So, I'm pretty much a noob still experimenting with basic > > commands. I wanted to make a code

Re: [Tutor] Python programming help!

2018-09-23 Thread Bob Gailer
On Sep 23, 2018 3:33 AM, "V E G E T A L" wrote: > > Hello folks! So, I'm pretty much a noob still experimenting with basic > commands. I wanted to make a code that checks if the value of one variable > is less, equal or greater than the other. Pretty simple right? But then, > this problem emerged

Re: [Tutor] Python programming help!

2018-09-23 Thread Mark Lawrence
On 21/09/18 16:12, V E G E T A L wrote: Hello folks! So, I'm pretty much a noob still experimenting with basic commands. I wanted to make a code that checks if the value of one variable is less, equal or greater than the other. Pretty simple right? But then, this problem emerged. I would really l

Re: [Tutor] python -m pip install vs pip install

2018-09-10 Thread Mats Wichmann
On 09/10/2018 09:10 AM, Alex Kleider wrote: > In another currently active thread Mats Wichmann recommends using: >   python -m pip install ... > vs >   pip install ... > > The question is how to install a specific version of python itself. > > I'm running Ubuntu 16.04 and have the following notes

Re: [Tutor] Python

2018-09-06 Thread Alan Gauld via Tutor
On 06/09/18 04:14, Donna Black via Tutor wrote: > How do we save our work on python? IDLE hasn’t installed itself on my > computer Which OS are you using? That will help us find/install IDLE. However, you don't need IDLE to work with Python, just a text editor. If I assume you are using Window

Re: [Tutor] "Python not recognized as a command"

2018-09-01 Thread Mats Wichmann
On 09/01/2018 04:24 PM, Marc Tompkins wrote: > On Sat, Sep 1, 2018 at 10:40 AM, Dana O'Connor > wrote: > >> Hi, >> I've been trying to download and use Python 3.7 for the past few days and >> every time I try to open it it tells me I don't have "pip" which should be >> impossible because this ver

Re: [Tutor] "Python not recognized as a command"

2018-09-01 Thread Marc Tompkins
On Sat, Sep 1, 2018 at 10:40 AM, Dana O'Connor wrote: > Hi, > I've been trying to download and use Python 3.7 for the past few days and > every time I try to open it it tells me I don't have "pip" which should be > impossible because this version of Python is supposed to automatically come > with

Re: [Tutor] "Python not recognized as a command"

2018-09-01 Thread Alan Gauld via Tutor
On 01/09/18 18:40, Dana O'Connor wrote: > I've been trying to download and use Python 3.7 for the past few days How exactly did you download it (from which site and in which format?) And how did you then install it? > every time I try to open it it tells me I don't have "pip" That seems unlik

Re: [Tutor] Python Memory Allocation -- deep learning

2018-07-30 Thread Steven D'Aprano
On Tue, Jul 31, 2018 at 02:58:56AM +1000, Steven D'Aprano wrote: > The *only* thing you have seen which is a language feature is this rule: > > - if two objects, a and b, have the same ID *at the same time*, then > "a is b" will be true; > > - if "a is b" is false, then a and b must have diff

Re: [Tutor] Python Memory Allocation -- deep learning

2018-07-30 Thread Steven D'Aprano
On Mon, Jul 30, 2018 at 09:21:01AM -0600, Mats Wichmann wrote: > (id does not necessarily mean memory location, by the way) id() *never* means memory location in Python. id() *always* returns an opaque integer ID number which has no promised meaning except to be unique while the object is alive

Re: [Tutor] Python Memory Allocation -- deep learning

2018-07-30 Thread Max Zettlmeißl via Tutor
On Mon, Jul 30, 2018 at 3:20 PM, Sunil Tech wrote: > Python memory allocation is varying in all these use cases. Please help me > understand. CPython is interning small integers and small strings as a form of optimisation. "The current implementation keeps an array of integer objects for all int

Re: [Tutor] Python Memory Allocation -- deep learning

2018-07-30 Thread Steven D'Aprano
On Mon, Jul 30, 2018 at 06:50:59PM +0530, Sunil Tech wrote: > Hi Team, > > I am investigating how the memory allocation happens in Python You cannot investigate memory allocation in Python code, because the Python execution model does not give you direct access to memory. What you can investiga

Re: [Tutor] Python Memory Allocation -- deep learning

2018-07-30 Thread Mats Wichmann
On 07/30/2018 07:20 AM, Sunil Tech wrote: > Hi Team, > > I am investigating how the memory allocation happens in Python There are several things going on here, but the main thing to know is: but Python language _implementations_ optimize when they can and think it makes sense. So don't draw too m

Re: [Tutor] Python Memory Allocation -- deep learning

2018-07-30 Thread Joel Goldstick
On Mon, Jul 30, 2018 at 9:20 AM, Sunil Tech wrote: > Hi Team, > > I am investigating how the memory allocation happens in Python > For Eg: > *Case 1:* > a = 10 b = 10 c = 10 id(a), id(b), id(c) > (140621897573616, 140621897573616, 140621897573616) a += 1 id(a) > 14062

Re: [Tutor] Python Question

2018-05-16 Thread Alan Gauld via Tutor
On 15/05/18 22:26, Mahamed Ahmed wrote: > Please I would like you to help me solve the problem above We see no problem. this is a text only list so if you included a binary attachment the server will have stripped it off for security reasons. Please repost the text of the problem description and

Re: [Tutor] Python Question

2018-05-16 Thread Mats Wichmann
On 05/15/2018 03:26 PM, Mahamed Ahmed wrote: > Hello, > > Please I would like you to help me solve the problem above which is related > to loops and prime numbers so please get back to me, I also want to know how > to sign up and get a online tutor for this python course > > Here is what is sup

Re: [Tutor] Python C extension - which method?

2018-05-07 Thread Michael C
Sorry I don't understand your suggestion. Use "ctypes.CDLL" and "ctypes.WinDLL" this works, mydll = cdll.LoadLibrary('test.dll') print(mydll.sum(3,2)) and this doens't mydll = cdll('test.dll') print(mydll.sum(3,2)) What's the syntax of what you suggested? Thanks On Mon, May 7, 2018 at 3:15 AM

  1   2   3   4   5   6   7   8   9   10   >