Re: [Tutor] Telnet login

2012-11-08 Thread Dave Angel
"\n") if password: tn.read_until("Password: ") tn.write(password + "\n") tn.write("ls\n") tn.write("exit\n") print tn.read_all() >>> >>> > Dave Angel wrote: >> >> This is a text mailing list; your html mail thorough

Re: [Tutor] Parsing a multi-line/record text file

2012-11-10 Thread Dave Angel
On 11/11/2012 12:01 AM, Marc wrote: > Hello, > > I am trying to parse a text file with a structure that looks like: > > [record: Some text about the record] So the record delimiter starts with a left bracket, in first column? And all lines within the record are indented? Use this fact. >

Re: [Tutor] Connecting to a DB via a function call

2012-11-11 Thread Dave Angel
On 11/11/2012 06:39 AM, Khalid Al-Ghamdi wrote: > Hi, > > Why is it that the following even though I call the below function? And how > do I write a function that makes connection that I can use to query my DB? > > Traceback (most recent call last): > File "C:/Python33/My Stuff/schedule_machine/s

Re: [Tutor] Questions about classes

2012-11-13 Thread Dave Angel
On 11/12/2012 09:49 PM, brandon w wrote: > I have been trying to understand classes. I have been studying from a book > I picked up recently. > I have two questions about them. > > 1. I saw in the book an assignment written like this: > > class HumanBeing: > def makeName(self, name): >

Re: [Tutor] writing files using modules and functions

2012-11-13 Thread Dave Angel
On 11/13/2012 01:43 AM, Rufino Beniga wrote: > def MatInv(arr,file): > f = open('file.txt','w') > f.write(arr) > f.close() > > So I'm trying to write a module that will take a matrix (arr) and write it > to a text file. > The above module is called MatrixIO.py > > #first I import it > >

Re: [Tutor] LCM

2012-11-14 Thread Dave Angel
On 11/14/2012 12:52 PM, Selby Rowley Cannon wrote: > Hey, > > I've been trying to write a function to find the Lowest Common > Multiple of two numbers, but it isn't working and I've kinda hit a > dead end on the thought-process end of things. Anyone mind looking at > it, and tell me what's wron

Re: [Tutor] LCM

2012-11-14 Thread Dave Angel
On 11/14/2012 01:34 PM, Selby Rowley Cannon wrote: > On 14/11/12 18:27, Dave Angel wrote: >> On 11/14/2012 12:52 PM, Selby Rowley Cannon wrote: >>> Hey, >>> Tell us what version of Python you're targeting. I'm going to assume 2.x, since you have print witho

Re: [Tutor] unicode help

2012-11-14 Thread Dave Angel
On 11/14/2012 03:10 PM, Marilyn Davis wrote: > Hi, > > Last year, I was helped so that this ran nicely on my 2.6: > > #! /usr/bin/env python > # -*- coding: utf-8 -*- > # necessary for python not to complain about "¥" > > symbol = unichr(165) > print unicode(symbol) > > --- end of code --- > > But,

Re: [Tutor] unicode help

2012-11-14 Thread Dave Angel
On 11/14/2012 04:07 PM, Marilyn Davis wrote: > > > Goodness! I didn't expect it to be a Mac thing. > > So, on a Windows machine, running Python 2.6.6, sys.stdout.encoding is > 'cp1252', yet the code runs fine. > > On Ubuntu with 2.7, it's 'UTF-8' and it runs just fine. > > I find this most myste

Re: [Tutor] Plot multiple lines using python / basemap

2012-11-15 Thread Dave Angel
On 11/15/2012 04:20 AM, Boris Vladimir Comi wrote: > > Hi all: > > I have begun to learn about python / matplolib / basemap and really need some > help. > > My data is in an Excel workbook with the following structure: > > Evento FechaLatitud

Re: [Tutor] Quick question about definitions.

2012-11-17 Thread Dave Angel
On 11/16/2012 12:28 PM, sillywilly98 wrote: > I know this code is not fully debugged. I just cant see why 1 definition is > wrong. > Here is the code: > # This program draws a robot. > > from turtle import * > > def draw_eyes(): > # This fu

Re: [Tutor] LCM

2012-11-18 Thread Dave Angel
On 11/18/2012 12:50 PM, Andrew wrote: > On Wed, 14 Nov 2012 19:52:03 +0200, Selby Rowley Cannon > wrote: > >> Hey, >> >> I've been trying to write a function to find the Lowest Common >> Multiple of two numbers, but it isn't working and I've kinda hit a >> dead end on the thought- >> I hav

Re: [Tutor] Beginner's question

2012-11-22 Thread Dave Angel
On 11/22/2012 10:14 AM, Joel Goldstick wrote: >> > Peter O'Doherty wrote: >>> > > >>> < snip > >>> > > I need to write a program that examines 3 variables x, y, z, and prints >>> > > the largest odd number. I've tried all sorts of variations and this is >>> > > the current version: >>> > > > x

Re: [Tutor] Beginner's question

2012-11-22 Thread Dave Angel
On 11/22/2012 02:50 PM, eryksun wrote: > On Thu, Nov 22, 2012 at 10:49 AM, Dave Angel wrote: >> >>> >>> >> >> This one first gets into trouble if x is even and y is odd, because if >> tries to compare y with None, which is basically an undefined

Re: [Tutor] Beginner's question

2012-11-22 Thread Dave Angel
On 11/22/2012 06:57 PM, eryksun wrote: > On Thu, Nov 22, 2012 at 6:49 PM, Steven D'Aprano wrote: >>> will give the same answer each time, for a single run of a script in >>> CPython, but it is unspecified what that answer will be, and may vary by >>> version as well as implementation. >> Correct.

Re: [Tutor] doctest question

2012-11-27 Thread Dave Angel
On 11/27/2012 04:50 AM, Albert-Jan Roskam wrote: > >> On 27/11/12 08:06, Albert-Jan Roskam wrote: >>> (Steven D'Aprano wrote, even though the indentation is wrong) >>> >>> >>> >>> Doctesting anything to do with dictionaries is tricky, because you >>> cannot rely on the order of a dict. There are

Re: [Tutor] manipulating a string in python

2012-11-27 Thread Dave Angel
On 11/27/2012 11:49 AM, Dave Wilder wrote: Could you please use text mode in your messages? Your email editor produces double-spacing when it converts the html stuff you wrote into the text this forum supports. > > > I believe there is a simple answer to this, but I am confused on what > direct

Re: [Tutor] reverse diagonal

2012-12-01 Thread Dave Angel
On 12/01/2012 10:40 AM, richard kappler wrote: > I'm working through Mark Lutz's "Python," reviewing the section on lists. I > understand the list comprehension so far, but ran into a snag with the > matrix. I've created the matrix M as follows: > > M = [[1, 2, 3[, [4, 5, 6], [7, 8, 9]] There's an

Re: [Tutor] reverse diagonal

2012-12-01 Thread Dave Angel
On 12/01/2012 11:28 AM, Brian van den Broek wrote: > On 1 December 2012 10:40, richard kappler wrote: >> I'm working through Mark Lutz's "Python," reviewing the section on lists. I >> understand the list comprehension so far, but ran into a snag with the >> matrix. I've created the matrix M as fol

Re: [Tutor] reverse diagonal

2012-12-01 Thread Dave Angel
On 12/01/2012 09:19 PM, eryksun wrote: > On Sat, Dec 1, 2012 at 11:31 AM, Dave Angel wrote: >> >> revdiag = [M[i][len(M)-1-i] for i in range(len(M)) ] > > You might sometimes see this using the bitwise invert operator ~ (i.e. > __invert__, operator.invert): > >

Re: [Tutor] reverse diagonal

2012-12-01 Thread Dave Angel
On 12/01/2012 09:55 PM, eryksun wrote: > On Sat, Dec 1, 2012 at 9:35 PM, Dave Angel wrote: >> >> [M[i][~i] for i,dummy in enumerate(M) ] > > Since enumerate() iterates the rows, you could skip the first index: > > >>> [row[~i] for i,row in enumerate(

Re: [Tutor] To Find the Answers

2012-12-01 Thread Dave Angel
On 12/01/2012 11:39 PM, Sujit Baniya wrote: > *Write a function named countRepresentations that returns the > number*>* of ways that an amount of money in rupees can be represented > as rupee*>* notes. For this problem we only use rupee notes in > denominations of*>* 1, 2, 5, 10 and 20 rupee notes

Re: [Tutor] 1 to N searches in files

2012-12-02 Thread Dave Angel
On 12/02/2012 03:53 AM, Spectral None wrote: > Hi all > > I have two files (File A and File B) with strings of data in them (each > string on a separate line). Basically, each string in File B will be compared > with all the strings in File A and the resulting output is to show a list of > match

Re: [Tutor] how to struct.pack a unicode string?

2012-12-02 Thread Dave Angel
On 12/02/2012 08:34 AM, Albert-Jan Roskam wrote: > > > > > > > Hi Eryksun, > > Observation #1: Yes, makes perfect sense. I should have thought about that. > Observation #2: > As I emailed earlier today to Peter Otten, I thought unicode_internal means > UCS-2 or UCS-4, > depending on the size o

Re: [Tutor] 1 to N searches in files

2012-12-03 Thread Dave Angel
On 12/03/2012 10:46 AM, Spectral None wrote: > > Hi Dave > > Your solution seems to work: > > setA = set(FileA) > setB = set(FileB) > > for line in setB: > if line in setA: > matched_lines.writelines(line) > else: > non_matched_lines.writelines(line) > > There are no duplicates in

Re: [Tutor] On understanding defintions

2012-12-04 Thread Dave Angel
On 12/04/2012 01:29 PM, frank ernest wrote: > Opensuse 12.2 python3.2 > I discoverd that some of the examples for definitions in the tutorial are > not valid. I am reporting this as a bug. And what are the bug numbers? Or links to the bug reports? Otherwise why are you telling us about them wi

Re: [Tutor] On understanding defintions

2012-12-04 Thread Dave Angel
les you found "bugs" in. Could be the page they're on was meant for a different version of Python than what you're running. For example, in Python 2.x, 'print' was a statement, while in 3.x it's a function. >> - Original Message - >> From:

Re: [Tutor] I'm trying to wrap my head around defs

2012-12-04 Thread Dave Angel
On 12/04/2012 04:51 PM, frank ernest wrote: > Opensuse 12.2 python3.2 > I'm having trouble understanding them. > Python is my first language... excluding English. > I've already read ALL OF THE PYTHON Language Referance and I still don't > "get it." You usually should start with a tutorial, no

Re: [Tutor] Get/Set/Attribute Accessors in Python?

2012-12-05 Thread Dave Angel
On 12/05/2012 10:38 AM, Malcolm Newsome wrote: > Hey Tutors, > > Python is/was my first language. Yet, I've recently begun learning C# for > my new job. > > One thing I've come across in C# (and, quite frankly, am having a difficult > time grasping) is Get and Set (Accessors). > > Since, I don't e

Re: [Tutor] Tutor Digest, Vol 106, Issue 5

2012-12-05 Thread Dave Angel
On 12/05/2012 03:50 PM, Prasad, Ramit wrote: > >> >> Not to mention that as social conventions regarding email have moved >> on--e.g. top posting--for the majority of email users A bug that somehow convinced people that it was "normal." So other implementers copied the bug. -- DaveA __

Re: [Tutor] Tutor Digest, Vol 106, Issue 5

2012-12-05 Thread Dave Angel
On 12/05/2012 04:22 PM, Alan Gauld wrote: > > > > PPS. > There is one advantage to lazy top posting. When I return from > vacation I sort by subject and only open the most recent in a thread. > That way I can read up from the bottom and get all the others in one > go. I then just delete the rest u

Re: [Tutor] reading web page with BeautifulSoup

2012-12-12 Thread Dave Angel
On 12/12/2012 08:47 PM, Ed Owens wrote: > >>> from urllib2 import urlopen > >>> page = urlopen('w1.weather.gov/obhistory/KDCA.html') > Traceback (most recent call last): > File "", line 1, in > File > "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", > line 1

Re: [Tutor] New Re: Clearing Python text

2012-12-14 Thread Dave Angel
On 12/14/2012 10:25 AM, Waters, Mike [ITSCA Non-J&J] wrote: > Hi Tutor, > I am using Win 7 ,Python 2.7. Interpreter. > To state my challenge : When I have filled a page with values and text until > it reaches the bottom of the screen, how can I highlight this and remove to > allow further entries

Re: [Tutor] Get the structure values from a c file

2012-12-16 Thread Dave Angel
On 12/16/2012 10:12 PM, Marefe Serentas wrote: > Hi, I need help. > > I want to create a python script that will store the value of the > structure /MainStruct/ from the c file. > Suppose my c file looks like this: > -- > #define max (3) > > t

Re: [Tutor] Get the structure values from a c file

2012-12-18 Thread Dave Angel
On 12/17/2012 11:25 PM, Marefe Serentas wrote: > On 12/18/2012 12:38 AM, tutor-requ...@python.org wrote: >> Re: Get the structure values from a c file > I apologize for some syntax errors in my c file. I would like to correct > my mistakes and append some lines in the c file to make it clearer. > >

Re: [Tutor] need help with python for counter

2012-12-19 Thread Dave Angel
On 12/19/2012 12:40 AM, Brandon Merritt wrote: > I feel silly, but I'm having the darndest time trying to figure out why > this for counter won't work. I know that there is the count method for the > string class, but I was just trying to do it the syntactical way to prove > myself that I know the

Re: [Tutor] how to control putty window

2012-12-20 Thread Dave Angel
On 12/20/2012 09:25 AM, Ufuk Eskici wrote: > > I run this command and opens putty: > > import os > import subprocess > command = '"c:\Program Files\Putty\putty.exe" -ssh > ufukeskici@10.10.10.10-pw test > subprocess.Popen(command) > > You really should use cut and paste when trying to tell us what

Re: [Tutor] invalid literal for int error in Game loop

2012-12-20 Thread Dave Angel
On 12/20/2012 03:51 PM, Steven D'Aprano wrote: > On 21/12/12 07:40, Ciaran Mooney wrote: > >> def difficultyLevel(): >> FPS = '' > > Here you set the variable FPS to the empty string. > >> if event.type == KEYDOWN: >> if event.key == ord('b'): >> FPS = 30

Re: [Tutor] invalid literal for int error in Game loop

2012-12-20 Thread Dave Angel
On 12/20/2012 04:34 PM, Ciaran Mooney wrote: > Thanks for the feedback. > > Steve, If I set the FPS to a default of say 30, the game seems to run at this > default FPS=30 regardless of the key pressed in the function. > > Dave, If I remove the the default value at the start of the function and a

Re: [Tutor] check it for me

2012-12-22 Thread Dave Angel
On 12/22/2012 04:02 PM, Farrukh Ali wrote: > Hi Tutor, > > I am new to python, and a novice in the world of programming, I am learning > python from learnpythonthehardway, and now a little bit confused in exercise > 3, where the author of the book wants us to rewrite the ex3.py by saying > Rewri

Re: [Tutor] check it for me

2012-12-22 Thread Dave Angel
On 12/22/2012 05:38 PM, Farrukh Ali wrote: > Hi, i am using ActivePython 2.7.2.5, and windows 8 professional. > well the original ex3.py is: > print "I will now count my chickens:" > print "Hens", 25 + 30 / 6 > print "Roosters", 100 - 25 * 3 % 4 > print "Now I will count the eggs:" > print 3 + 2 +

Re: [Tutor] For Loop Question

2012-12-23 Thread Dave Angel
On 12/23/2012 09:02 PM, Alan Gauld wrote: > On 24/12/12 01:16, Mitya Sirenef wrote: >> On 12/23/2012 08:03 PM, Tom Tucker wrote: >>> >>> >>> Python Gurus, >>> I got a question for ya. Below I have three instance variables >>> (self.A, self.B, etc). How can I use the below >>> for loop for A, B, C

Re: [Tutor] how to control putty window

2012-12-27 Thread Dave Angel
On 12/27/2012 04:53 AM, Ufuk Eskici wrote: > It seems it is looking for Paramiko under wrong folder. > import paramiko > Traceback (most recent call last): > File "", line 1, in > import paramiko > File "C:/Users/eufuesk/Desktop\paramiko.py", line 3, in > ssh = paramiko.SSHClient

Re: [Tutor] Trouble importing Paramiko

2012-12-27 Thread Dave Angel
On 12/27/2012 06:44 AM, Ufuk Eskici wrote: First comment: please don't top-post. You've done it many times now, and it's not how this forum works. Put your comments after the parts you're quoting. (My email is mostly busted; I've been trying to send this for hours) First question: what vers

Re: [Tutor] another for loop question - latin square

2012-12-30 Thread Dave Angel
On 12/30/2012 06:59 PM, Brandon Merritt wrote: > I am having trouble Please tell us what Python version you're targeting. It looks like 2.7, but you really should specify it for us. Next, you should tell us your skill level; are you experienced at another language and learning Python, or what?

Re: [Tutor] another for loop question - latin square (was: Tutor Digest, Vol 106, Issue 74)

2013-01-01 Thread Dave Angel
On 01/01/2013 08:27 PM, Brandon Merritt wrote: > Sorry, I should have been more clear in what I was trying to accomplish. I > am trying to build the latin square as follows: > > 1234567 > 2345671 > 3456712 > 4567123 > 5671234 > 6712345 > 7123456 > > So, the "scaleorder" is the n*n scale of the squa

Re: [Tutor] Limitation of int() in converting strings

2013-01-02 Thread Dave Angel
On 01/02/2013 11:41 AM, Steven D'Aprano wrote: > > > The bit about __index__ refers to using trunc(): > > "I still really wish I had followed Pascal's lead instead of C's here: > Pascal requires you to use trunc() to convert a real to an integer. ... > If we had done it that way, we wouldn't have

Re: [Tutor] Python Programming for Absolute Beginner

2013-01-02 Thread Dave Angel
On 01/02/2013 08:20 PM, Conor Grevlos wrote: > I downloaded the python source folder, with chapters 1 through 12 I think. > But it just opens up the program that is already built, not one that shows me > the code. > Starting a new thread with each message is unproductive and impolite. If you ac

Re: [Tutor] Decorators: Are they good for checking inputs and outputs?

2013-01-06 Thread Dave Angel
On 01/06/2013 07:13 PM, DoanVietTrungAtGmail wrote: > *.. Could you perhaps give a concrete example of a situation where > a decorator would be useful for checking the inputs to a function? .. Oscar* > > Say I write a function that expects 5 positional arguments, and up to 4 ** > arguments. Now I w

Re: [Tutor] Here is code, no link for my previous question

2013-01-06 Thread Dave Angel
On 01/06/2013 09:07 PM, Jack Little wrote: > Here is the code, my error is below the code in itallics This is a text mailing list, italics aren't generally visible. If you want to highlight a line, add a useful comment to it. But the problem here is your scoping. All those globals make no sens

Re: [Tutor] Flow charts

2013-01-09 Thread Dave Angel
On 01/09/2013 09:26 PM, Ed Owens wrote: > I'm working my way through Chun's book "Core Python Applications > Programming" and can't get one of the examples to actually work. In > trying to analyze the problem (good learning approach) I had troubles > understanding the interactions between the two

Re: [Tutor] Problem with calling class methods stored in a list

2013-01-10 Thread Dave Angel
On 01/10/2013 06:36 AM, Tobias M. wrote: > Peter Otten wrote: >> Build the list outside the class: MyClass.method_list = [MyClass.bar] > Thanks, that is a solution. But I don't really like to put the list > outside the class as it is strongly related to the class and not used > outside. But as it

Re: [Tutor] garbage collection/class question

2013-01-10 Thread Dave Angel
On 01/10/2013 09:06 AM, richard kappler wrote: Since you don't specify Python version or implementation, I'll use CPython version 2.7 for the details below. Jython (for java environments) and other implementations are likely to differ in their garbage collection details. But the effect will be t

Re: [Tutor] garbage collection/class question

2013-01-11 Thread Dave Angel
On 01/11/2013 02:41 PM, Jan Riechers wrote: > On 10.01.2013 19:50, Mitya Sirenef wrote: >> On 01/10/2013 09:06 AM, richard kappler wrote: >> >> class Tree(object): >> height = 0 >> >> def grow(self): >> self.height += 1 >> >> You may have a dozen of related functions and you can

Re: [Tutor] Binary/Decimal convertor

2013-01-11 Thread Dave Angel
On 01/11/2013 04:51 PM, Ghadir Ghasemi wrote: > Hi, I made a program called binary/denary convertor. Can anyone tell me about > how I could stop the user entering a binary number with more than 8 numbers > or 8 bit by repeating the question over and over until they do enter a > correct binary nu

Re: [Tutor] Working with output of a subprocess

2013-01-11 Thread Dave Angel
On 01/11/2013 05:29 PM, 3n2 Solutions wrote: > Hello, > > Need some help with working with a text file. > Is it possible to get the values associated with each of the parameter in > the below text file format? For example: There are no intrinsic parameters and values in a text file. it's free for

Re: [Tutor] run perl script files and capture results

2013-01-11 Thread Dave Angel
On 01/11/2013 07:33 PM, Prasad, Ramit wrote: > [snip] > Why not just use r'C:\Python27\\'? Might be too confusing for > a beginner to remember, I suppose. > > Because that'd have two trailing backslashes. (in Python 2.7 anyway) -- DaveA ___ Tutor m

Re: [Tutor] (no subject)

2013-01-12 Thread Dave Angel
On 01/12/2013 12:32 PM, Ali Raza Ghasemi wrote: > I have to make a program that adds binary numbers together. The program has > to accept two binary values (up to 8 binary digits) and output their total in > binary. The output should not contain any leading zeros. > I have a problem in that I don

Re: [Tutor] Adding Binary

2013-01-12 Thread Dave Angel
On 01/12/2013 03:43 PM, Ali Raza Ghasemi wrote: > I am making a program that adds binary numbers together. The program has to > accept two binary values (up to 8 binary digits) and output their total in > binary. The output should not contain any leading zeros. > I have a problem in that I don't

Re: [Tutor] text files

2013-01-15 Thread Dave Angel
On 01/15/2013 09:31 PM, Gina wrote: I have version 3 I am trying to read a text file ("the_file.txt") and then write a new file where the characters are in uppercase but i don't know how/where i should use the .upper I think i should use it where the ** is, but i got errors when i tried t

Re: [Tutor] Set LD_LIBRARY_PATH and equivalents platform-independently

2013-01-16 Thread Dave Angel
On 01/16/2013 07:05 PM, Alan Gauld wrote: On 16/01/13 21:06, Albert-Jan Roskam wrote: Is there a builtin function that can set LD_LIBRARY_PATH or equivalents platform-independently? No. But there is putenv() in the os module. But how well it works across OS I'm not sure. I don't recall eno

Re: [Tutor] Python's OOP-Inheritance make me confuse.

2013-01-19 Thread Dave Angel
On 01/19/2013 02:08 AM, Moore John wrote: Hi, I am new to Python language. I have only 10 days experience on it. When I start learning there is no difficult, but it make me slow down when I reach "Object Oriented Concept", especially "Inherited". Some of my background knowledge about "Inherited i

Re: [Tutor] Calculate hours

2013-01-22 Thread Dave Angel
On 01/22/2013 09:52 PM, anthonym wrote: Hello All, I originally wrote this program to calculate and print the employee with the most hours worked in a week. I would now like to change this to calculate and print the hours for all 8 employees in ascending order. The employees are named employee

Re: [Tutor] Calculate hours

2013-01-22 Thread Dave Angel
On 01/22/2013 10:08 PM, Mitya Sirenef wrote: On 01/22/2013 09:52 PM, anthonym wrote: Hello All, > > I originally wrote this program to calculate and print the employee > with the most hours worked in a week. I would now like to change this > to calculate and print the hours for all 8 employ

Re: [Tutor] Calculate hours

2013-01-23 Thread Dave Angel
On 01/22/2013 11:18 PM, anthonym wrote: Thanks Dave I think I would like to keep it simple. How would I get it to repeat and print before deleting? To repeat something, write a loop. So you have a while loop *outside* the one you've written (you'll have to indent your present loop another

Re: [Tutor] Calculate hours

2013-01-23 Thread Dave Angel
On 01/23/2013 06:13 PM, Alan Gauld wrote: On 23/01/13 03:08, Mitya Sirenef wrote: To make the change you need, use list comprehension to make sums of all rows, sort it (using list sort method); iterate over it using enumerate() and print out "employee N, sum of hours:" One problem with that a

Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Dave Angel
On 01/24/2013 08:46 AM, Matthew Ngaha wrote: hi guys i am a python 3.1.1. user but really need to use python 2 to be able to use certain libraries and frameworks. i have installed python 2.7 but they cant run together as all .py and .pyw files are opened with python 3. i can open simple python 2

Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Dave Angel
On 01/24/2013 11:11 AM, Matthew Ngaha wrote: Python 3.3 for Windows comes with a "launcher", which will approximate (for Python only) what Unix and Linux users have had for years for any scripting language. You can get it separately, as Mark Lawrence has said, but maybe it's time to bring your

Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Dave Angel
On 01/24/2013 01:26 PM, Matthew Ngaha wrote: yes the 2nd option (standalone pylauncher) sounds more convienient for me. i just have to try and comprehend all the instructions given.. hopefully ill get there in the end i managed to install the laucher. on the site when i click the correct launch

Re: [Tutor] how can i use python 2 alongside 3?

2013-01-24 Thread Dave Angel
On 01/24/2013 01:56 PM, Matthew Ngaha wrote: Have you added shebang lines to those scripts yet? yes i added them. i think the problem is at the start where it asks me to: You should ensure the launcher is on your PATH - depending on how it was installed it may already be there, but check just

Re: [Tutor] Python Help

2013-01-26 Thread Dave Angel
On 01/23/2013 04:37 PM, Grady Trexler wrote: Below is my code. I am using python 2.4 It tells me I have a syntax error. I don't see any such thing. Plesae include the traceback, which will indicate WHERE you have a syntax error. And if you look yourself, you'll probably spot it, since it's

Re: [Tutor] Facebook login using python

2013-01-28 Thread Dave Angel
On 01/28/2013 10:40 AM, Aaron Misquith wrote: I am working on a program which is used to login to facebook, get my friend lists using graph api and export them into pdf format. So far i'm able to login with facebook and get the friend list. I would like if someone is able to provide me a code to

Re: [Tutor] HELP-Regarding python

2013-01-29 Thread Dave Angel
On 01/30/2013 01:51 AM, Gayathri S wrote: Hi All! I don't know how to read text file in python. If the data values are stored in a text file format, for example(1,30,60,90,120...200) means what i would do for reading it in python. could you just explain it. infile = open

Re: [Tutor] Need to be able to accept Page Down or CTRL-E

2013-01-31 Thread Dave Angel
On 01/31/2013 09:43 PM, Dave Wilder wrote: Hello, In a script I am writing, I would like to be able to accept the PAGE DOWN key as an input as well as the arrow keys. Is that possible w/ Python (I am using python 2.7.3 and Linux OS)? If so, could someone point me to documentation on how to

Re: [Tutor] Need to be able to accept Page Down or CTRL-E

2013-01-31 Thread Dave Angel
On 01/31/2013 10:19 PM, Dave Wilder wrote: On 01/31/2013 09:43 PM, Dave Wilder wrote: Hello, In a script I am writing, I would like to be able to accept the PAGE DOWN key as an input as well as the arrow keys. Is that possible w/ Python (I am using python 2.7.3 and Linux OS)? If so, coul

Re: [Tutor] Need to be able to accept Page Down or CTRL-E

2013-02-01 Thread Dave Angel
On 02/01/2013 03:34 AM, Alan Gauld wrote: OTOH if you mean you want to send the page up/down/arrows as the "something" then its a different game and you can do it. In that case you need todo what you did with ESC. The character set your external app uses will determine the codes you send. As

Re: [Tutor] Read from large text file, parse, find string, print string + line number to second text file.

2013-02-01 Thread Dave Angel
On 02/01/2013 03:09 PM, Scurvy Scott wrote: Hey all how're things? I'm hoping for some guidance on a problem I'm trying to work through. I know this has been previously covered on this list but I'm hoping it won't bother you guys to run through it again. My basic program I'm attempting to creat

Re: [Tutor] Read from large text file, parse, find string, print string + line number to second text file.

2013-02-01 Thread Dave Angel
On 02/01/2013 04:24 PM, Scurvy Scott wrote: One last question on this topic.. I'd like to call the files and the string form the command line like Python whatever.py STRINGTOSEARCH NEWFILE FILETOOPEN My understanding is that it would be accomplished as such import sys myString = sys.argv[1]

Re: [Tutor] Help

2013-02-01 Thread Dave Angel
On 02/01/2013 08:47 PM, Jack Little wrote: I get this error Traceback (most recent call last): File "C:\Users\Jack\Desktop\python\g.py", line 56, in path1pt1() NameError: name 'path1pt1' is not defined With this amount of code: def simpstart(): global ammo1 global ammo2 glob

Re: [Tutor] pickle.dump yielding awkward output

2013-02-03 Thread Dave Angel
On 02/03/2013 02:26 PM, Spyros Charonis wrote: Hello Pythoners, I am experiencing a strange result with the pickle module when using it to write certain results to a separate file. In short, I have a program that reads a file, finds lines which satisfy some criteria, and extracts those lines, s

Re: [Tutor] pickle.dump yielding awkward output

2013-02-03 Thread Dave Angel
(top-posting and offline response fixed) On Sun, Feb 3, 2013 at 11:07 PM, Dave Angel wrote: On 02/03/2013 02:26 PM, Spyros Charonis wrote: Hello Pythoners, I am experiencing a strange result with the pickle module when using it to write certain results to a separate file. In short, I have

Re: [Tutor] Iterating a dict with an iteration counter? How would *you* do it?

2013-02-04 Thread Dave Angel
On 02/04/2013 12:13 PM, Modulok wrote: List, Simple question: Is there a common pattern for iterating a dict, but also providing access to an iteration counter? Here's what I usually do (below). I'm just wondering if there are other, more clever ways:: data = {'a': "apple", 'b': "banana",

Re: [Tutor] Iterating a dict with an iteration counter? How would *you* do it?

2013-02-04 Thread Dave Angel
On 02/04/2013 12:58 PM, Modulok wrote: Hmm.. no kidding. Well, at least I knew I was over-complicating it. Cheers! -Modulok- Please don't top-post. Another point. I don't currently have Python 3.x installed, but I seem to remember that in Python 3 you can use the dict itself as an iterator

Re: [Tutor] Iterating a dict with an iteration counter? How would *you* do it?

2013-02-04 Thread Dave Angel
On 02/04/2013 06:18 PM, Steven D'Aprano wrote: On 05/02/13 09:26, Dave Angel wrote: Another point. I don't currently have Python 3.x installed, but I seem to remember that in Python 3 you can use the dict itself as an iterator providing both key and value. If I'm right, t

Re: [Tutor] Getting range of a list

2013-02-05 Thread Dave Angel
On 02/05/2013 04:08 PM, Hs Hs wrote: First comment: do NOT post in html, as it frequently messes up indenting. Send your email in text mode, as this is a text mailing list. Compounding that, you apparently are running inside some shell program (pyshell ?) which is doing a further mess.

Re: [Tutor] Getting range of a list

2013-02-05 Thread Dave Angel
On 02/05/2013 04:48 PM, Hs Hs wrote: Thanks Steve. But one question, when I print, I get extra empty lines. How to get rid of them! Thanks again. f = open('test') head = '---' for line in f: line = line.rstrip() #get rid of the trailing newline (and any other whitespace there) if li

Re: [Tutor] recursive function password check

2013-02-06 Thread Dave Angel
On 02/06/2013 09:26 AM, Noriko Tani wrote: Hi Mara, Several suggestions: Put the password in a list, then loop each letter to check if it is a vowel like this No need to make it a list, strings are already iterable. And you don't make it a list in the code, just in the remark above. pa

Re: [Tutor] recursive function password check

2013-02-06 Thread Dave Angel
On 02/06/2013 08:44 AM, Mara Kelly wrote: Hi everyone, trying to write a program that has the user enter a password, checks if it contains any vowels, and if it does prints ' It is false that password(whatever the user enters) has no vowels,' and if it has no vowels prints it is True that pass

Re: [Tutor] How to override getting items from a list for iteration

2013-02-10 Thread Dave Angel
On 02/10/2013 09:32 AM, Walter Prins wrote: Hello, I have a program where I'm overriding the retrieval of items from a list. As background: The data held by the lists are calculated but then read potentially many times thereafter, so in order to prevent needless re-calculating the same value o

Re: [Tutor] How to override getting items from a list for iteration

2013-02-10 Thread Dave Angel
On 02/10/2013 10:10 AM, Dave Angel wrote: On 02/10/2013 09:32 AM, Walter Prins wrote: Hello, I have a program where I'm overriding the retrieval of items from a list. As background: The data held by the lists are calculated but then read potentially many times thereafter, so in ord

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-10 Thread Dave Angel
On 02/11/2013 12:14 AM, neubyr wrote: I have a text file with each line in following format: Book Name, Author Name, Genre, Publication Date I would like to perform following queries on this file: * Get all books written by an author * Remove all books of an author * Get information about

Re: [Tutor] Truncated urlopen

2013-02-11 Thread Dave Angel
On 02/11/2013 05:58 AM, Válas Péter wrote: Hi tutors, aboard again after a long time. Welcome back. http://..._export.php?mehet=1 is a link which exports me some data in CSV correctly when I click on it in my browser. (It contains personal data, that's why I dotted.) I want to process it dir

Re: [Tutor] help with inch to cms conversion .

2013-02-11 Thread Dave Angel
On 02/11/2013 11:06 AM, Pravya Reddy wrote: Can you please help me with the code. #!/usr/bin/env python """ inchtocm.py """ First, remove that try/except until the code is free of obvious bugs. It's masking where the error actually occurs. Alternatively, include a variable there, and print

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-11 Thread Dave Angel
On 02/11/2013 01:19 PM, Alan Gauld wrote: On 11/02/13 05:14, neubyr wrote: * How do I associate/relate Book and Author classes so that it will help me in getting information like 'get list of books written by an author'? Data attribute? I woudn't have a separate Author class but, if you

Re: [Tutor] calling and returning functions.

2013-02-11 Thread Dave Angel
On 02/11/2013 03:07 PM, Pravya Reddy wrote: Can you please complete the code. #!/usr/bin/env python """ One function receives a value in inches and returns the equivalent value in cms like cm = 2.54 * in.The other function receives a value in cms and returns the equivalent value in inches like i

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-12 Thread Dave Angel
On 02/12/2013 12:32 PM, neubyr wrote: On Mon, Feb 11, 2013 at 7:34 PM, Steven D'Aprano wrote: I am not following your comment on opening books file twice in list_by_author method. I have opened it only once and then reading each line while checking for a regex match. Am I missing something?

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-14 Thread Dave Angel
On 02/14/2013 12:35 PM, Prasad, Ramit wrote: neubyr wrote: I am not sure how to save an object in memory to a file before exiting the program. Any examples or related documentation links would be really helpful. I am guessing it would be using some kind of before teardown method, but not sure

Re: [Tutor] Newbie Here -- Averaging & Adding Madness Over a Given (x) Range?!?!

2013-02-14 Thread Dave Angel
On 02/14/2013 03:55 PM, Michael McConachie wrote: Hello all, This is my first post here. I have tried to get answers from StackOverflow, but I realized quickly that I am too "green" for that environment. As such, I have purchased Beginning Python (2nd edition, Hetland) and also the $29.00 co

Re: [Tutor] associating two objects without ORM and processing a text file

2013-02-14 Thread Dave Angel
On 02/14/2013 04:33 PM, Prasad, Ramit wrote: Dave Angel wrote: On 02/14/2013 12:35 PM, Prasad, Ramit wrote: neubyr wrote: I am not sure how to save an object in memory to a file before exiting the program. Any examples or related documentation links would be really helpful. I am guessing it

Re: [Tutor] New User-Need-Help

2013-02-15 Thread Dave Angel
On 02/15/2013 06:28 PM, Mark Lawrence wrote: On 15/02/2013 22:31, Joel Goldstick wrote: Sorry, you said above python 3. In python 3 raw_input was changed to input. so change that and it will work for you. There are some differences between 2 and 3 that you will need to look out for. Go to th

<    6   7   8   9   10   11   12   13   14   15   >