[Tutor] Trouble with SUM()

2019-04-20 Thread Ju Bo
Hi, I'm trying to write a program that uses a while loop to ask a user for multiple values then use the program to add all the values, however many there may be, then print the sum. I'm having trouble with the sum() function. My code is below: con = "y" while con == "y": AMT = float(in

Re: [Tutor] delete strings from specificed words

2018-01-11 Thread YU Bo
Hi, On Thu, Jan 11, 2018 at 11:40:35AM +1100, Cameron Simpson wrote: On 09Jan2018 22:20, YU Bo wrote: The text i will working as follow: ```text [...] diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index a789f952b3e9..443892dabedb 100644 [...] +++ b/tools/perf/util/util.c

Re: [Tutor] delete strings from specificed words

2018-01-10 Thread YU Bo
Hi, On Wed, Jan 10, 2018 at 10:37:09AM +0100, Peter Otten wrote: YU Bo wrote: index 45a63e0..3b9b238 100644 ... ``` I want to delete string from *diff --git* to end, because too many code is here Use str.split() or str.partition() and only keep the first part: text = """Th

Re: [Tutor] delete strings from specificed words

2018-01-10 Thread YU Bo
Hi, First, thank you very much for your reply. On Tue, Jan 09, 2018 at 10:25:11PM +, Alan Gauld via Tutor wrote: On 09/01/18 14:20, YU Bo wrote: But, i am facing an interesting question.I have no idea to deal with it. I don;t think you have given us enough context to be able to help

[Tutor] delete strings from specificed words

2018-01-09 Thread YU Bo
Hi, I am learning python to reslove issue,which make happy:) But, i am facing an interesting question.I have no idea to deal with it. The text i will working as follow: ```text [PATCH] perf tools: Fix copyfile_offset update of output offset We need to increase output offset in each iteration

Re: [Tutor] Fahrenheit to Celsius Conversion another problem and Programming Paradigm

2017-06-15 Thread Bo Yu
On Thu, Jun 15, 2017 at 12:52:10PM +, Neil Cerutti wrote: On 2017-06-14, Peter Otten <__pete...@web.de> wrote: Sebastian Silva wrote: Or shorter: if unit in 'Cc': Don't do that. You are in for nasty surprises: def check(unit): ... if unit in "Cc": ... return "Celsius" ...

[Tutor] Python Projects

2014-12-07 Thread Bo Morris
The book arrived this morning. Thanks Alan! Bo ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Help understanding classes

2014-11-15 Thread Bo Morris
Thank you Alan and Danny. It amazes me at the lengths you guys, as well as everyone else who contributes, will go to to help explain things to us; it is greatly appreciated! Alan, I decided to dumb down the learning classes just a little. By this I mean, I am not using Tkinter to learn classes

[Tutor] I apologize

2014-11-15 Thread Bo
I accidentally sent my last email from my work email. I recently added my gmail account to MS exchange and I forget I have to change where I send the mail from now that I have two accounts in exchange. Sorry for any confusion. ___ Tutor maillist - Tut

[Tutor] Help understanding classes

2014-11-14 Thread Bo
Hello everyone, hope all is well. Was just wondering if I could get some help understanding classes and how they work. What is the point in OOP if I don¹t understand classes, are classes not the heart and soul of OOP? I have been trying to learn classes by practicing with Tkinter building GUIs. Bel

Re: [Tutor] Practicing with sockets

2014-10-31 Thread Bo Morris
Users/Bo/Desktop/SIG.png', 'r') strf = f.read() client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client_socket.connect(("25.78.28.110", 8999)) while True: client_socket.send(struct.pack("!I", len(strf))) data = client_socket.sendall(strf

Re: [Tutor] Practicing with sockets

2014-10-31 Thread Bo Morris
not yet learned how to deal with this. Would I be better off converting the image to base64 prior to sending it to the server, then decoding it on the server? Here is my updated code...for brevity sake, I have omitted the "import" statments... Client: f = open('/Us

[Tutor] Practicing with sockets

2014-10-31 Thread Bo Morris
Hello all, hope everyone is doing well. I have been practicing with sockets and I am trying to send a small png from the client to the server. the client code is... import socket f = open('/Users/Bo/Desktop/logo_ONEConnxt.png', 'rb') strf = f.read() client_socket = socket.s

Re: [Tutor] Code critique

2014-10-24 Thread Bo Morris
Thank you all for the helpful criticism. I wish I was able to catch on to what you are suggesting more quickly. Based on your recommendations, I have come up with the following so far, however I just dont see it as easily as I did while using the if/elif statements. This is what I have so far. I

Re: [Tutor] Code critique

2014-10-24 Thread Bo Morris
"...Regarding your program, instead of writing long sequences of repetitive if conditions, I would write one function for each of the different operations and store them in a dict, mapping each host name to a function (and multiple host names may map to the same function). Then, look up the host na

[Tutor] Code critique

2014-10-24 Thread Bo Morris
Hello all, May I please get a little instructional criticism. The code below works. It logs into 9 different Linux computers, runs a couple commands, and then transfers a file back to the server. I want to become a better Python coder; therefore, I was hoping for some ways to make the below code b

[Tutor] Insert time into email...final code

2014-10-22 Thread Bo Morris
Just in case anyone else can benefit from this, here is my working code up to this point #!/usr/bin/python import smtplib from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText from email.MIMEImage import MIMEImage import time strFrom = "HourlyReport.com" strTo = "mye

[Tutor] Insert time into email

2014-10-20 Thread Bo Morris
hello all, hope everyone is doing well. The below code works, however I am going back and trying to enter the time and date and I cant quite figure out how to do this without breaking the code. #!/usr/bin/python import smtplib from email.MIMEMultipart import MIMEMultipart from email.MIMEText imp

[Tutor] printing all text that begins with "25"

2014-10-02 Thread Bo Morris
Hello all, hope everyone is doing well. When I run the linux command "hamachi list" i get something along the lines of the following output 087-888-279 Pandora25.x.x.xxx alias: not set 096-779-867 AM1LaptopBD-PC25.x.x.xxx alias: not set

[Tutor] command counter

2014-09-05 Thread Bo Morris
Here is the shell script I am trying to recreate in python. Sorry for not posting this with my other emails...I am a bit off today. restart_count=10 count=10 restart=5 while ((count--)); do avconv -v verbose -re -analyzeduration 0 | ./bmdplay -m 2 -f pipe:0 echo "Retry" if [[ $count = 1

[Tutor] command counter

2014-09-05 Thread Bo Morris
I think I figured it out... each time I run subprocess.Popen("command"), I also have to count += 1, which adds 1 to count each time the command is run. Is this correct, or is there a better way? Thanks ___ Tutor maillist - Tutor@python.org To unsubscr

[Tutor] command counter

2014-09-05 Thread Bo Morris
how would I keep track of count for each time a command exectuted? for example... subprocess.Popen("command") && add 1 to count. If count equals n number, do something. I have tried count = 0 count += 1, but count does not seem to be incrementing. Thanks

[Tutor] interacting with stderr

2014-08-30 Thread Bo Morris
Here is my working code. It works great in the lab, but I still need to test it on a live system. I also need to add the email notifications to it, but I purposely left them out for now; I will also adjust the sleep time to a more appropriate amount. Anyone see any issues with it or ways to make it

Re: [Tutor] Quantum computing (Alan Gauld)

2013-12-14 Thread Bo Morris
tor Digest, Vol 118, Issue 62 (Keith Winston) >4. Re: list comprehension equivalent to map(function,list item) > (Bo Morris) >5. Re: weird lambda expression -- can someone help me understand > how this works (Alan Gauld) >6. Re: Quantum computing (Alan Gauld) &

Re: [Tutor] list comprehension equivalent to map(function, list item)

2013-12-14 Thread Bo Morris
reference? Again, thank you. AngryNinja On Fri, Dec 13, 2013 at 9:24 PM, Amit Saha wrote: > On Sat, Dec 14, 2013 at 11:03 AM, Bo Morris wrote: > > i have the following simple function that iterates over the list. It > passes > > the list item into the function and adds the nu

[Tutor] list comprehension equivalent to map(function, list item)

2013-12-13 Thread Bo Morris
i have the following simple function that iterates over the list. It passes the list item into the function and adds the numbers. What would be the equivalent way of writing the "map" portion with list comprehension? My code is as follows: def add(number): print 1 + int(number) x = ['2', '4

[Tutor] Nested loop of I/O tasks

2009-11-24 Thread Bo Li
Dear Python I am new to Python and having questions about its usage. Currently I have to read two .csv files INCT and INMRI which are similar to this INCT NONAME 121.57 34.71 14.81 1.35 0 0 1 Cella 129.25 100.31 27.25 1.35 1 1 1 Chiasm 130.3 98.49 26.05 1.35 1 1 1 FMagnum 114.89 144.94 -

Re: [Tutor] help with erros using subprocess module

2006-05-10 Thread Bo Yang
Jerome Jabson 写道: > Hi, > > I've been trying to write a wrapper around some shells > scripts using the subprocess module. But I'm getting > errors I quite don't know how to debug. I've only been > writing Python for a few months and starting processes > are new to me. Here's my code: > > import os

Re: [Tutor] Any stuff about python interpreter design ?

2006-03-09 Thread Bo Yang
y apologies to the > list, but it's my honest answer.] > > Hi Bo, > > There are several books and online material about the writing of > interpreters. The ones that I'm most aware aware of that are aimed at > beginner programmers, though, target the language 'Sc

[Tutor] Any stuff about python interpreter design ?

2006-03-09 Thread Bo Yang
Hello , I have learned and used python half a year , and I like this language very much . I used it in my web server page , in my homework and part-tiem job . Recently , I feel very interested in the python interpreter . So I take a look into the source code .But I get confused about so many files