[Tutor] a par2 creator and verification program

2019-07-23 Thread Adam Gold
Hello everyone. I'm thinking through a short program I want to write that will 'par2'/generate ECCs for all of my work files which branch out from a single directory and number approximately 15,000. Specifically: 1) day one: - create a mirror copy of the directory tree empty of all files

Re: [Tutor] graphics library for teaching Python

2018-12-21 Thread Adam Eyring
On Fri, Dec 21, 2018, 3:26 AM Michael Mossey wrote: > > There are two sub-topics I'm interested in - (1) graphics, as in drawing > interesting pictures or art, or using diagrams for data visualization. (2) > Simple games, with the use of sprites. > One that hasn't been mention in yours and

Re: [Tutor] Import CSV

2018-12-13 Thread Adam Eyring
Take a look at the book Automating the Boring Stuff with Python (free PDF): https://automatetheboringstuff.com/ There's a couple of chapters in there for downloading CSV files and extracting the data. On Thu, Dec 13, 2018 at 1:57 PM Sammy Lee wrote: > I need help on how to open a webpage and

Re: [Tutor] Any 'graphical' ways of learning Python

2018-12-05 Thread Adam Eyring
I've liked turtle and make my graphing more interesting by asking for user input such as dimensions, then graph automatically. One starter source for using pygame graphics is https://inventwithpython.com/pygame/ It jumps into game writing very quickly, but provides explanations of commands. The

Re: [Tutor] Beginners Book, Python and PyScripter

2018-12-04 Thread Adam Eyring
I haven't gone through many python books, but have been using a copy of Automating the Boring Stuff with Python. It covers lists, dictionaries, scraping data from websites, etc. https://automatetheboringstuff.com/ The PDF is free. Adam On Tue, Dec 4, 2018 at 1:09 PM James Stapleton-Cotton wrote

Re: [Tutor] Request for help with code

2018-11-07 Thread Adam Eyring
When I post code with questions, I just copy and paste from Python IDLE 3.6. Colors are removed, but indentation is preserved. On Tue, Nov 6, 2018 at 6:59 PM Mats Wichmann wrote: > On 11/6/18 4:36 PM, Joseph Gulizia wrote: > > Funny using a text editorand showed indented in my browser.

Re: [Tutor] Installing python

2018-11-03 Thread Adam Eyring
On Fri, Nov 2, 2018 at 8:10 PM Mark Lawrence wrote: > On 02/11/2018 22:49, Alan Gauld via Tutor wrote: > > On 02/11/2018 21:13, Roger Lea Scherer wrote: > > > >> I have installed python 3.7 on my computer Windows10 > >> (C:\Users\Roger\AppData\Local\Programs\Python\Python37), > > > > Caveat: I'm

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? > > >

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] Tutor Digest, Vol 176, Issue 13

2018-10-12 Thread Adam Eyring
Also, try (works for me in Python3) rivers = {'nile' : 'egypt', 'ohio' : 'US', 'rhine' : 'germany' } for key, value in rivers.items(): print (key) for key, value in rivers.items(): print (value) for key, value in rivers.items(): print ("The " + key + " is in the country of " +

Re: [Tutor] Help please

2018-10-12 Thread Adam Eyring
The program works as is in Python3. For Python2, change input to raw_input and see if that makes it work (I know it worked for me when I had Python2). Also, it looks better to use " + " instead of a comma: print("Combining these foods will you," + new_food) Also, colons and spaces are good

[Tutor] Pip issue

2018-10-05 Thread Adam Eyring
here's get-pip.py, but the documentation on using it is confusing. Thanks for your help. Adam ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

[Tutor] Help

2018-07-03 Thread Adam Jones
", multipoint_size="0") # JOIN RandomFile (CID) to DonutFile (OBJECTID) arcpy.JoinField_management(in_data="RandomFile", in_field="CID", join_table="DonutFile", join_field="OBJECTID", fields="") # DELETE unnecessary fields in

Re: [Tutor] QT5 pyqt5 for python 2.7

2017-11-19 Thread adam ghering
gmail.com> Sent: Saturday, November 18, 2017 2:09:41 AM To: tutor@python.org Subject: Re: [Tutor] QT5 pyqt5 for python 2.7 On 18/11/17 01:51, adam ghering wrote: > Hello, > > I am trying to get up to speed on python; expand my skills etc. > > I work in a VFX environment where most al

[Tutor] QT5 pyqt5 for python 2.7

2017-11-18 Thread adam ghering
Hello, I am trying to get up to speed on python; expand my skills etc. I work in a VFX environment where most all the tools continue to run with python 2.7XX I have seen that pyqt5 supports python 2.7 according to its documentation but it needs to be rebuilt to function. I have done some

[Tutor] Need help with one problem.

2017-02-15 Thread Adam Howlett
Write an if-else statement that assigns 20 to the variable y if the variable x is greater than 100. Otherwise, it should assign 0 to the variable y. Is there an easy way to solve this problem? ___ Tutor maillist - Tutor@python.org To unsubscribe or

Re: [Tutor] My Query - How to implement multi threading with remote execution capability in python to achieve parallel processing

2014-12-23 Thread Adam Jensen
This thread is hilarious. Thanks for the chuckle. http://www.ignyte.ms/whitepapers/LayersOf%20HumanValuesInStrategy.pdf http://www.principiadiscordia.com/downloads/04%20Prometheus%20Rising.pdf On Mon, 22 Dec 2014 11:27:01 + Vishwas Pathak vishwas_pat...@persistent.com wrote: I am working

Re: [Tutor] print() invalid syntax error

2014-12-23 Thread Adam Jensen
On Tue, 23 Dec 2014 18:27:10 + stuart kurutac scoobydoo...@hotmail.com wrote: finish = (int(input(Finish: )) The parenthesis aren't balanced. I would have written it as: finish = int(input(Finish: )) but something like this should also work: finish = (int(input(Finish: )))

Re: [Tutor] Learning to program, not code.

2014-12-21 Thread Adam Jensen
On Sun, 21 Dec 2014 21:15:43 +1100 Ben Finney ben+pyt...@benfinney.id.au wrote: Use a distributed version control system (Mercurial is good and is written in Python) I'm beginning to really appreciate [fossil](http://fossil-scm.org/). Re: Learning to program, not code. Is that like learning

Re: [Tutor] lottery problem (Was Re: (no subject))

2014-12-19 Thread Adam Jensen
On Fri, 19 Dec 2014 10:32:15 +0100 Peter Otten __pete...@web.de wrote: Basically from random import randint, seed is equivalent to import random randint = random.randint seed = random.seed del random From that you can deduce that the whole random module is loaded into memory in

Re: [Tutor] lottery problem (Was Re: (no subject))

2014-12-18 Thread Adam Jensen
On Fri, 19 Dec 2014 00:55:49 + Alan Gauld alan.ga...@btinternet.com wrote: You could have used a list instead of all the individual variables line[0] = ... line[1] = ... But then you could get clever and use a loop: while lines != 0: start = 1 period = 7 for lineNum

Re: [Tutor] lottery problem (Was Re: (no subject))

2014-12-18 Thread Adam Jensen
On Thu, 18 Dec 2014 20:27:03 -0500 Adam Jensen han...@riseup.net wrote: And to build the 'lines' list (although, this is getting rather ugly): lines = [[random.randint(x,x+6) for x in range(1,50,7)] for i in range(7)] Oops, in the context of the original program this might make more sense

Re: [Tutor] Need help!

2014-12-13 Thread Adam Jensen
On Fri, 12 Dec 2014 07:46:05 -0500 Jagannath Ramanan jagannath.rama...@gmail.com wrote: My name is jag. I need little bit of help understanding something. I have a vncserver running at the background in redhat. My client is lubuntu where im using python. For some reason the communication is

Re: [Tutor] Memory management in Python

2014-12-09 Thread Adam Jensen
On Wed, 26 Nov 2014 14:08:53 + Raúl Cumplido raulcumpl...@gmail.com wrote: This web is quite useful to visualize what is happening: http://www.pythontutor.com/visualize.html#mode=edit Very nifty web app, thanks for the link! ___ Tutor maillist

[Tutor] pexpect interactive password entry for luks device

2014-11-24 Thread Adam Gold
I'm trying to do something really simply (I think) with pexpect but must be missing an obvious step. I want to ssh from host to guest, establish a CIFS connection on the guest to a share somewhere else on the local network, open a luks loop device on the share by entering the password (I don't

Re: [Tutor] Dividing a float derived from a string

2014-11-21 Thread Adam Jensen
-Original Message- From: Tutor [mailto:tutor-bounces+hanzer=riseup@python.org] On Behalf Of Alan Gauld Sent: Thursday, November 20, 2014 7:24 PM But that's considered bad practice, it's better to put the valid errors only in the except line like this: try: print

Re: [Tutor] Dividing a float derived from a string

2014-11-20 Thread Adam Jensen
#!/usr/bin/env python3.4 good = False s = input('Enter a number: ') a = s.split('.') n = len(a) if n = 2: for y in a: if y.isdigit(): good = True else: good = False exit else: good = False if good: num = float(s) print(num * 12)

Re: [Tutor] Data chart

2014-11-20 Thread Adam Jensen
import fileinput def parseLine(a): x = a.split('/') b = x[1].split(':') c = b[0].split('.') y = c[0] z = int(b[2]) return x[0], y, z print('{:4}{:10}{:8}{:8}'.format('','canofica','lnvd','msd')) data = [0, 0, 0] prevDate = None for line in fileinput.input():

Re: [Tutor] Dividing a float derived from a string

2014-11-20 Thread Adam Jensen
On Thu, 20 Nov 2014 21:20:27 + Stephanie Morrow svmor...@gmail.com wrote: Hi there, I have been posed with the following challenge: Create a script that will ask for a number. Check if their input is a legitimate number. If it is, multiply it by 12 and print out the result. I was

Re: [Tutor] subprocess.Popen basics

2014-10-28 Thread Adam Jensen
Update: On 10/27/2014 09:50 PM, Adam Jensen wrote: What's weird is that I have two different python3.4 installations on this CentOS-6.5 machine and both have the same behavior (script hangs until Ctrl+C). I built this one (/opt/bin/python3.4) from source: ... But this one (~/anaconda3/bin

Re: [Tutor] subprocess.Popen basics

2014-10-28 Thread Adam Jensen
On 10/28/2014 02:32 PM, Alan Gauld wrote: I tried -1 and 1 on my Lubuntu and it still works fine. Definitely weird, it begins to look like a CentOS build issue but what is CentOS doing different to Lubuntu/Suse/OpenBSD etc? From memory CentOS is basically a free version of Red Hat

Re: [Tutor] subprocess.Popen basics

2014-10-28 Thread Adam Jensen
On 10/28/2014 04:27 PM, Todd wrote: Centos has SELinux enabled by default. I dont know if SELinux is causing your problem, but it is always worth looking at. SELinux can keep a process from accessing files or executing another process. Try temporarily disabling SELinux by running

[Tutor] subprocess.Popen basics

2014-10-27 Thread Adam Jensen
Hi, I'm exploring Popen today and I seem to be having some trouble deciphering the [documentation][1]. [1]: docs.python.org/3/library/subprocess.html#popen-constructor In this example (below), I expect to start a shell script as a separate process, send a line of text through a pipe (to the

Re: [Tutor] subprocess.Popen basics

2014-10-27 Thread Adam Jensen
On 10/27/2014 03:40 PM, David Abbott wrote: It hangs at the print statement and, from the sound of the fans in the computer, I suspect it spirals off into an infinite loop somewhere / somehow. Does anyone have any ideas about what it is that I might be misunderstanding? Works here.

Re: [Tutor] subprocess.Popen basics

2014-10-27 Thread Adam Jensen
On 10/27/2014 07:12 PM, Alan Gauld wrote: On 27/10/14 18:24, Adam Jensen wrote: It hangs at the print statement and, from the sound of the fans in the computer, I suspect it spirals off into an infinite loop somewhere It works fine on my Lubuntu 14 with Python3.4. How exactly are you

Re: [Tutor] subprocess.Popen basics

2014-10-27 Thread Adam Jensen
On 10/27/2014 03:40 PM, David Abbott wrote: It hangs at the print statement and, from the sound of the fans in the computer, I suspect it spirals off into an infinite loop somewhere / somehow. Does anyone have any ideas about what it is that I might be misunderstanding? Works here.

Re: [Tutor] subprocess.Popen basics

2014-10-27 Thread Adam Jensen
On 10/27/2014 09:31 PM, Alan Gauld wrote: On 27/10/14 20:26, Adam Jensen wrote: That's a bit bizarre. I too have the execution bit set for both the python script and the shell script but the same (no joy) behavior occurs on both: $ ./subprocess_pipe.py Its a long shot but try

[Tutor] Standard Library Performance (3.4.1)

2014-10-24 Thread Adam Jensen
I'm tinkering this evening and I've noticed that math.factorial() is much faster than my plain python implementations. import math def factorial(n): temp = 1 for k in range(0,n): temp = temp * (n - k) return(temp) def fac(n):

Re: [Tutor] Standard Library Performance (3.4.1)

2014-10-24 Thread Adam Jensen
On 10/24/2014 08:01 AM, Stefan Behnel wrote: Alan Gauld schrieb am 24.10.2014 um 13:03: Not all library modules are C based however so it doesn't always apply. But they are usually optimised and thoroughly debugged so it is still worth using them rather than building your own. It's worth

Re: [Tutor] A question about using stdin/out/err vs named files

2014-10-19 Thread Adam Jensen
On 10/18/2014 02:36 PM, George R Goffe wrote: Hi, When you run a python program, it appears that stdin, stdout, and stderr are opened automatically. I've been trying to find out how you tell if there's data in stdin (like when you pipe data to a python program) rather than in a named

Re: [Tutor] code review

2014-06-13 Thread Adam Gold
On 12/06/14 00:38, Alan Gauld wrote: HTH Thanks Alan and Lukáš for your very helpful comments. I will attempt to revise the script in light of them and will revert if I hit any brick walls :) ___ Tutor maillist - Tutor@python.org To unsubscribe

Re: [Tutor] code review

2014-06-11 Thread Adam Gold
On 11/06/14 00:04, Steven D'Aprano wrote: On Tue, Jun 10, 2014 at 04:51:20PM +0100, Adam Gold wrote: Hi there. I've been writing a script that is now finished and working (thanks, in part, to some helpful input from this board). What I'd really like to do now is go through it with an 'expert

Re: [Tutor] code review

2014-06-11 Thread Adam Gold
called lurking, I believe. So I would say, please do this on the list, and many more people than Adam may benefit. Others can ignore the thread if they wish. Bob Oke doke, here it is below. Just for convenience's sake, I'm going to repeat what the basic steps are. It's a backup script

[Tutor] code review

2014-06-10 Thread Adam Gold
Hi there. I've been writing a script that is now finished and working (thanks, in part, to some helpful input from this board). What I'd really like to do now is go through it with an 'expert' who can point out ways I may have been able to code more efficiently/effectively. I don't think it

Re: [Tutor] gnupg within a for loop

2014-06-02 Thread Adam Gold
On 01/06/14 18:28, Danny Yoo wrote: Hi Adam, Ah; I've seen this before. Make sure the file name is either relative to current working directory, or make the file name absolute. What's happening is that os.listdir() is giving you file names that are relative to the base directory you've

Re: [Tutor] gnupg within a for loop

2014-06-02 Thread Adam Gold
On 02/06/14 01:35, Danny Yoo wrote: Thanks Danny, that was spot on. I actually used os.chdir to change to the base directory (which I assigned to a variable) just before the open statement. I don't know if that's 'pythonically' correct but it seemed like a simple way to do it. Again, thank

[Tutor] gnupg within a for loop

2014-06-01 Thread Adam Gold
have to be inputted by the user). I start with the following which can be used to encrypt a single file (assume I have the indentations correct in the actual code, I can't seem to modify the wrapping with my email client): phrase = '12345' cipher = 'AES256' gpg = gnupg.GPG(gnupghome='/home/adam

Re: [Tutor] pipes and redirecting

2014-05-28 Thread Adam Gold
On 27/05/14 21:01, Adam Gold wrote: dd if=/home/adam/1 bs=4k conv=noerror,notrunc,sync | pbzip2 1.img.bz2 The first thing I do is break it into two assignments And that's the start of the problem because it should be three: The first command, the second command and the output file

[Tutor] pipes and redirecting

2014-05-27 Thread Adam Gold
I'm trying to run the following unix command from within Python as opposed to calling an external Bash script (the reason being I'm doing it multiple times within a for loop which is running through a list): dd if=/home/adam/1 bs=4k conv=noerror,notrunc,sync | pbzip2 1.img.bz2 The first thing I

[Tutor] Python Help

2014-04-09 Thread Adam Grierson
Hi I'm using 3D climate data (ending in “.nc”). The cube contains time, longitude and latitude. I would like to look at the average output over the last 20 years. The time field spans back hundreds of years and I only know how to collapse the entire field into a mean value. How can I tell

[Tutor] Benefit/Disadvantage to storing data as dictionary vs. in a class

2012-06-01 Thread Adam
is this better/worse or the same as creating a 'Room' class to store the data? Since a 'Room' only contains a large amount of data, but doesn't contain any functions, which form of storing the data is considered 'better'? Thank you, Adam ___ Tutor

Re: [Tutor] Benefit/Disadvantage to storing data as dictionary vs. in a class

2012-06-01 Thread Adam
much from good programming practices, but more attempting to number of resources the class will be using. Thank you, Adam On 6/1/2012 10:24 AM, James Reynolds wrote: If you have functions (or in this case methods) which will be used on a certain 'objects' data structure, a class representation

Re: [Tutor] ssh socks proxy

2012-05-17 Thread Adam Gold
look like if one used paramiko? On 17 May 2012, at 04:01, kushal.kumaran+pyt...@gmail.com wrote: kushal.kumaran+pyt...@gmail.com wrote: Adam Gold adamg...@lavabit.com wrote: I'm trying to write a 'simple' script that will set up a socks proxy over ssh and maintain the connection until

[Tutor] ssh socks proxy

2012-05-16 Thread Adam Gold
I'm trying to write a 'simple' script that will set up a socks proxy over ssh and maintain the connection until manually terminated. It's not possible to use key-based authentication so a password will need to be supplied. Also, note, the user is presented with a list of servers to choose

Re: [Tutor] Extremely simple question

2012-01-11 Thread Adam Stogner
You should be using double quotes on this line and you are missing the last quote: print 'You're not Chris! Should be: print You're not Chris! On Wed, Jan 11, 2012 at 8:17 AM, col speed ajarnco...@gmail.com wrote: On 11 January 2012 20:11, Max S. maxskywalk...@gmail.com wrote: I believe

Re: [Tutor] different behaviour in Idle shell vs Mac terminal

2012-01-09 Thread Adam Gold
Date: Sun, 8 Jan 2012 23:34:15 + From: Adam Gold To: Subject: [Tutor] different behaviour in Idle shell vs Mac terminal Message-ID: Content-Type: text/plain; charset=iso-8859-1 I have short piece of code I'm using to print a string to the terminal one letter at a time.? It works

[Tutor] different behaviour in Idle shell vs Mac terminal

2012-01-08 Thread Adam Gold
I have short piece of code I'm using to print a string to the terminal one letter at a time.  It works fine when I invoke the script from within Idle; each letter appears after the preceding one according to the designated time interval.  However if I run it in the Mac terminal ('python3

Re: [Tutor] OT: Drag and Drop GUI IDE ideas

2011-07-28 Thread Adam Bark
application. It creates code for many different platforms including mobile ones and it's DRM free. HTH, Adam. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] serial device emulator

2011-07-05 Thread Adam Bark
myserial as serial #import serial ## Use this in production port = serial.Serial() port.open() print port.write(hello, world) print port.read(3) I hope that makes it clearer to you. Adam. P.S. none of that code has been tested On 05/07/11 13:03, Edgar Almonte wrote: thanks chirs but i think i

[Tutor] Conceptual Question About Use of Python for Employee Training Program

2011-06-25 Thread Adam Carr
Good Morning: I am very new to Python but I am enjoying the learning process. I have a question about the application of Python to a problem at the industrial business where I work. My two main questions are: 1. Can Python be used to achieve the goals of the possible project? 2. Where are the

Re: [Tutor] Clunky Password maker

2011-05-25 Thread Adam Bark
On 25/05/11 19:54, Modulok wrote: Depending on what your passwords are going to be protecting, be aware that the default generator in the random module is: ...completely unsuitable for cryptographic purposes. If he's just planning on making a few passwords I think the period of 2**19937-1 of

[Tutor] Beginner needs help with tkinter and images

2011-05-17 Thread Adam Westrum
I've got a basic program going right now, with 4 buttons. Forward backward right and left. Each button goes to an image of a colored circle. Problem i'm having is that when you click a button, the picture appears. When you click another button, a different picture appears, but the first picture

Re: [Tutor] triple-nested for loop not working

2011-05-04 Thread Adam Lucas
On Wed, May 4, 2011 at 13:31, Spyros Charonis s.charo...@gmail.com wrote: Hello everyone, I have written a program, as part of a bioinformatics project, that extracts motif sequences (programmatically just strings of letters) from a database and writes them to a file. I have written another

Re: [Tutor] after(), how do I use it?

2011-04-25 Thread Adam Bark
. HTH, Adam. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] lambda

2011-03-19 Thread Adam Bark
. Map is another that works similarly. Have a look into functional programming as that's the branch of computer science those two functions and lambdas tend to come from I believe. http://docs.python.org/library/functions.html?highlight=lambda#reduce HTH, Adam

Re: [Tutor] multiple if and or statement

2011-03-14 Thread Adam Bark
, but in reality it should only print true once correct? Any string that isn't blank ie '' is true. In your test you've asked whether i == 'test1' is true or 'test2' is true not i == 'test2' is true. I hope that's not too confusing, I can make it clearer if you're having a problem. Adam

Re: [Tutor] Concatenating string

2011-02-22 Thread Adam Bark
the mathematical addition operation on the two numbers before converting it to binary. 2) You've already done that several times, just use bin() HTH, Adam. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org

Re: [Tutor] question regarding regular expression compile

2011-01-12 Thread Adam Bark
character. So your re should now look like this: test = re.compile(rMAT file (log|billing|util|carrier)\\\d{8} deleted) HTH, Adam. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman

[Tutor] paramiko error with put()

2010-12-23 Thread Adam Cryer
Hi I am using paramiko 1.7.6 fanny on microsoft windows xp v2002 service pack3 with python 2.4.2 I have the follwing script: *import paramiko hostname='blah' port=22 username='blah' password='blah' fullpath='root\\path\\file.xls' remotepath='/inbox/file.xls' self.client=

Re: [Tutor] role playing game - help needed

2010-12-07 Thread Adam Bark
Adam. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] calling a method within a function

2010-12-07 Thread Adam Bark
On 07/12/10 22:36, John wrote: Hello, I have a strange problem with a piece of code I've written. It's a bit overly complicated to make an example with, but the gist is below. But in the example below, it works. However, in my example, when I call the method from within the function, it returns

Re: [Tutor] Pyserial and invalid handle

2010-11-30 Thread Adam Bark
On 01/12/10 01:00, John Smith wrote: Hi, Walter - I got pywin32-214.win32-py2.7.exe because I have the Intel i7 (I'm guessing that the AMD versions are for the AMD processor). However, all of the exe offerings have the same Python not found in registry problem that started this whole thing.

Re: [Tutor] Random Number Question

2010-11-24 Thread Adam Bark
On 24/11/10 21:51, Jeff Goodwin wrote: Hello, I'm trying to find a way to use the random.randint function to generate a random number, but everytime I run the program it locks up IDLE. Here is what I have so far: import random def main(): x = input(Enter a number: ) y = input(Enter

Re: [Tutor] Random Number Question

2010-11-24 Thread Adam Bark
On 24/11/10 22:10, Jeff Goodwin wrote: Ok, I found the problem, I had saved the file as random.py looks like that was a no-no. Its working now that I changed the name. Thanks! Jeff Ah yes always avoid giving your modules names that appear in the standard library. It goes wrong, sometimes in

Re: [Tutor] Accessing columns of a CSV file

2010-11-17 Thread Adam Bark
to access the second column of values. I tried the direct route: for row in cr: ... print cr[1] ... You need to print the 2nd item of row not of the entire file ie print row[1] not print cr[1]. HTH. Adam. ___ Tutor maillist

Re: [Tutor] Assistance with Psuedocode

2010-11-17 Thread Adam Bark
On 18/11/10 00:49, Alan Gauld wrote: Joe Ohmer ohme...@mymail.nku.edu wrote The following code works well but I don't understand why the mysteryEffect code block changes the picture. Doesn’t 64*(r/64) just equal r? That dependfs on which version of Python you use. In earlier versions '/'

Re: [Tutor] While Loops: Coin Flip Game

2010-11-14 Thread Adam Bark
On 14/11/10 22:16, Dawn Samson wrote: Greetings, I'm a Python beginner and working my way through Michael Dawson's Python Programming for the Absolute Beginner. I'm stuck in a particular challenge that asks me to write a program that flips a coin 100 times and then tells you the number of

Re: [Tutor] if statement

2010-11-02 Thread Adam Bark
On 02/11/10 19:02, Glen Clark wrote: File /home/glen/workspace/test.py, line 19 if confirmed == y: ^ SyntaxError: invalid syntax Why does this not work??? PyDev says Expected:else It's hard to tell without context. Can you send the code around it as well?

Re: [Tutor] if statement

2010-11-02 Thread Adam Bark
, Adam. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] if statement

2010-11-02 Thread Adam Bark
On 02/11/10 19:36, christopher.h...@allisontransmission.com wrote: Glen Clark wrote on 11/02/2010 03:07:18 PM: in general you should use raw_input instead of input. SNIP confirmed = int(input(Are you happy with this? (y/n): ) It would appear that Glen is using python 3.x as he used the

Re: [Tutor] Summing up numbers in a file

2010-10-26 Thread Adam Bark
to iterate through a file, you could try saving the number of occurrences of each number in the file into a dictionary. Something like: if num in my_dict: my_dict[num] += 1 else: my_dict[num] = 1 HTH. Adam. ___ Tutor maillist - Tutor@python.org

Re: [Tutor] What is random.triangular() used for

2010-10-24 Thread Adam Bark
an import numpy as np should get that code to work. HTH Adam. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] What does TypeError: 'int' object is not iterablemean?

2010-10-23 Thread Adam Bark
On 23/10/10 13:38, Alan Gauld wrote: Steven D'Aprano st...@pearwood.info wrote It would have to be a *very* old version. The use of * as the width parameter in format strings goes back to the Dark Ages of Python 1.5: ... I believe this is a virtual copy of string formatting from C, in which

Re: [Tutor] searching for newlines does not work!

2010-10-23 Thread Adam Bark
it literally means the character '/' followed by the character 'n'. In your first example you put the characters into the string test and replaced the characters. The second example you have actual newlines and are searching for the characters /n which don't exist in your string. HTH, Adam

Re: [Tutor] Merging Text Files

2010-10-14 Thread Adam Lucas
Either way; nest the for loops and index with protein IDs or dictionary one file and write the other with matches to the dictionary: non-python pseudocode: for every line in TWO: get the first protein ID for every line in ONE: if the second protein ID is the same as the first:

Re: [Tutor] Converting from unicode to nonstring

2010-10-14 Thread Adam Bark
On 14/10/10 19:29, David Hutto wrote: On Thu, Oct 14, 2010 at 2:19 PM, Sander Sweerssander.swe...@gmail.com wrote: On 14 October 2010 16:14, David Huttosmokefl...@gmail.com wrote: (u'graph1', u'Line', u'222', u'BLUE', u'1,2,3,4', u'True', u'0,5,0,10') Which is a tuple of unicode

Re: [Tutor] Converting from unicode to nonstring

2010-10-14 Thread Adam Bark
On 14/10/10 20:21, David Hutto wrote: On Thu, Oct 14, 2010 at 2:58 PM, Adam Barkadam.jt...@gmail.com wrote: Actually, I needed it to be converted to something without a string attached to it. See a post above, and it was fixed by eval(), Thanks though. And I'm sure at some point

Re: [Tutor] Converting from unicode to nonstring

2010-10-14 Thread Adam Bark
On 14/10/10 20:33, David Hutto wrote: On Thu, Oct 14, 2010 at 3:31 PM, David Huttosmokefl...@gmail.com wrote: On Thu, Oct 14, 2010 at 3:24 PM, Adam Barkadam.jt...@gmail.com wrote: On 14/10/10 20:21, David Hutto wrote: On Thu, Oct 14, 2010 at 2:58 PM, Adam Barkadam.jt

Re: [Tutor] pickle problem

2010-10-12 Thread Adam Bark
](self) KeyError: '' What does this mean ? It means that it's trying to access a sequence with the key '' but it's not working. It looks like the problem is you're trying to open peak.html as a pickle but it is actually an html file. HTH, Adam

Re: [Tutor] Hiding Superclass Methods

2010-10-11 Thread Adam Bark
. print [].__setslice__.__doc__ x.__setslice__(i, j, y) == x[i:j]=y Use of negative indices is not supported. class TestSlice(object): ... def __getslice__(self, i, j): ... print i, j ... t = TestSlice() t[2:3] 2 3 HTH, Adam

Re: [Tutor] Hiding Superclass Methods

2010-10-11 Thread Adam Bark
On 11/10/10 23:52, Steven D'Aprano wrote: On Tue, 12 Oct 2010 01:55:10 am Adam Bark wrote: On 11/10/10 15:29, Denis Gomes wrote: Thank you both for your responses. I do have one other question if I use the method both of you describe. How do I go about implementing slicing

Re: [Tutor] selecting elements from dictionary

2010-09-15 Thread Adam Bark
On 15/09/10 15:31, Hs Hs wrote: Dear Steven, Thanks for your help. however I have a question, using: for key, value in xdic.items(): if 1 in value and 2 in value or 3 in value: print key also print keys that have values such as [1,2,3]. In cases where there is [1,2,3] and [1,2]

Re: [Tutor] Serial communication ...

2010-09-13 Thread Adam Bark
On 13/09/10 16:36, Markus Hubig wrote: Hi @all! I'm about to write a class for serial communication on Win32 and Linux which provides a method called talk to send something over the serial line, wait for the answer and returns it. My problem is, that I don't know how long the answer will be

Re: [Tutor] What's the best way to ask forgiveness here?

2010-09-13 Thread Adam Bark
On 13/09/10 19:31, Brian Jones wrote: I've been coding Python long enough that 'asking forgiveness instead of permission' is my first instinct, but the resulting code is sometimes clumsy, and I wonder if someone can suggest something I'm missing, or at least validate what's going on here in

Re: [Tutor] What's the best way to ask forgiveness here?

2010-09-13 Thread Adam Bark
On 13/09/10 20:12, Brian Jones wrote: Thanks for the replies so far. One thing that's probably relevant: once a directory is created, I can expect to write a couple of hundred files to it, so doing a 'try os.makedirs' right off the bat strikes me as coding for the *least* common case instead

Re: [Tutor] How to numerically sort strings that start with numbers?

2010-09-13 Thread Adam Bark
On 14/09/10 01:11, Pete O'Connell wrote: theList = [21 trewuuioi,3zxc,134445] print sorted(theList) Hi, the result of the sorted list above doesn't print in the order I want. Is there a straight forward way of getting python to print ['3zxc','21 trewuuioi','134445'] rather than ['134445', '21

Re: [Tutor] How to numerically sort strings that start with numbers?

2010-09-13 Thread Adam Bark
a new list rather than modifying your original. On Tue, Sep 14, 2010 at 10:41 AM, Adam Barkadam.jt...@gmail.com wrote: On 14/09/10 01:11, Pete O'Connell wrote: theList = [21 trewuuioi,3zxc,134445] print sorted(theList) Hi, the result of the sorted list above doesn't print in the order I

Re: [Tutor] Lost in the control flow

2010-08-13 Thread Adam Bark
On 11/08/10 18:14, Eduardo Vieira wrote: On Tue, Aug 10, 2010 at 1:56 PM, Adam Barkadam.jt...@gmail.com wrote: The problem is you don't call make_dict unless there's a FUEL SURCHARGE or multiple pins. Also you don't add the first pin to mydict[tracking] unless there's a FUEL SURCHARGE

Re: [Tutor] Lost in the control flow

2010-08-10 Thread Adam Bark
] unless there's a FUEL SURCHARGE. HTH, Adam. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] elif statement

2010-08-10 Thread Adam Bark
. Sudarshana. HTH, Adam. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

  1   2   3   >