[Tutor] smtplib problems ?

2005-11-21 Thread dave
uling) daemon to remind you an ever increasing number of times a day ;) - Got to love Linux\n\nCheers\n\nDave"""                         msg = ('Subject: Friendly reminder :)\r\nFrom: Dave Selby\r\nTo: '+\             email_addr+'\r\n\r\n'+bl

[Tutor] Don't understand this class/constructor call syntax

2011-07-22 Thread dave
rgument, but I guess it must be the transmit_path object passed in place of the usually implicit self... I'm just not sure how Python figures out that it's not pad_for_usrp... magic I guess! Thanks for your help, Dave ___ Tutor maillist - T

Re: [Tutor] Don't understand this class/constructor call syntax

2011-07-23 Thread dave
class at line 138): https://www.cgran.org/browser/projects/ucla_zigbee_phy/trunk/src/python/ieee802_15_4_pkt.py Thanks, Dave On Sat, 23 Jul 2011 13:09:07 +1000, Steven D'Aprano wrote > dave wrote: > > > class transmit_path(gr.top_block) > [...] > > self.packet_transmitter

Re: [Tutor] Don't understand this class/constructor call syntax

2011-07-24 Thread dave
I was dimly aware of the functioning of booleans, but I see now that it doesn't specify an actual boolean type. Still, the code confuses me. Is the usage of pad_for_usrp consistent with it being treated as a boolean? Why would the entire self reference be transmitted then? Example code again:

Re: [Tutor] Don't understand this class/constructor call syntax

2011-07-25 Thread dave
corresponding ieee802_15_4*.py files are in ./python (lib contains C++ code accessed via SWIG). I can probably puzzle it out with this info eventually, but if you want to comment further feel free. Thanks for your help Dave On Mon, 25 Jul 2011 10:26:11 +1000, Steven D'Aprano wrote > da

Re: [Tutor] Don't understand this class/constructor call syntax

2011-07-28 Thread dave
t for the implicit self parameter rather than in place of the pass_as_USRP=True parameter. Steven D'Aprano also replied on this subject and if I understand him, then it would require a special syntax that is not present in the GNU Radio code. Dave On Mon, 25 Jul 2011 08:08:54 +0100, Alan G

[Tutor] iPython check if user running script is root user (Linux)

2012-05-31 Thread Dave
Hi. What is the right way to have an iPython script check to see if the user is currently root? Here's how I do it in bash scripts: ## CHECK USERNAME PRIVILEGE if [ $(id -u) != "0" ];then echo "This script must be run as root."

Re: [Tutor] iPython check if user running script is root user (Linux)

2012-05-31 Thread Dave
Thanks. I like the integer-based option. Since this is my first question to the list, is it appropriate to reply with a "thanks, that solved it" or is that considered unnecessary? On Thu, May 31, 2012 at 6:30 PM, Emile van Sebille wrote: > On 5/31/2012 3:21 PM Dave said... > &g

[Tutor] special attributes naming confusion

2012-06-06 Thread Dave
I was reading some tutorial material on creating iterators. It shows the following example implementation of an iterator: class Reverse: """Iterator for looping over a sequence backwards.""" def __init__(self, data): self.data = data self.index = len(data) def __iter__(

Re: [Tutor] special attributes naming confusion

2012-06-06 Thread Dave
On Wed, Jun 6, 2012 at 3:30 PM, Prasad, Ramit wrote: > > My question is how was I supposed to kinow that the function I call > using the > > name iter() is implemented using the name __iter__()? > > > > Is there a rule that describes when I would implement an attribute name > with > > leading and

Re: [Tutor] special attributes naming confusion

2012-06-06 Thread Dave
On Wed, Jun 6, 2012 at 3:40 PM, Mark Lawrence wrote: > On 06/06/2012 20:19, Dave wrote: > >> I was reading some tutorial material on creating iterators. It shows the >> following example implementation of an iterator: >> >> class Reverse: >> ""&

Re: [Tutor] special attributes naming confusion

2012-06-06 Thread Dave
r; for mappings, __iter__() <http://docs.python.org/reference/datamodel.html#object.__iter__>should be the same as iterkeys(); for sequences, it should iterate through the values. This is in addition to some missing documentation regarding mention how some of the special method names should

[Tutor] Global presets ?

2004-12-04 Thread Dave S
Hi there, I have some common data directories, like /home/dave/mygg/gg1.3/logs /home/dave/mygg/gg1.3/data /home/dave/mygg/gg1.3/datacore /home/dave/mygg/gg1.3/arch_data which increasing numbers of scripts are accessing. At the begining of each script I end up putting in declarations like

Re: [Tutor] Global presets ?

2004-12-04 Thread Dave S
Thanks Guys, They are both good ways of getting round my problem, I appreciate your input & will have a play. Cheers Dave :-) :-) :-) :-) ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Global presets ?

2004-12-04 Thread Dave S
Alan Gauld wrote: have you considered making the root directory an environment variable? That way you can read the value (os.getenv) at the start of the script. And if you ever need to move the structure you can simply change the environment value. It also means different users can use their own st

[Tutor] Accuracy of time.sleep()

2004-12-04 Thread Dave S
OK this is not a world stopping problem, more of a curiosity. Any suggestions Dave ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Accuracy of time.sleep()

2004-12-04 Thread Dave S
I expected the script to re-start 2-3 seconds after 8:05, python reloading after a long sleep etc, what I get is the script restarting at 08:04.55, earlier ??? OK this is not a world stopping problem, more of a curiosity. Any suggestions Dave Thanks for your input guys, I have used cron

Re: [Tutor] Accuracy of time.sleep()

2004-12-04 Thread Dave S
Tim Peters wrote: First, thank you for such a brilliant answer :-) [Dave S <[EMAIL PROTECTED]>] OK I may be pushing it, ;-) Yup . I need a script to sleep from any point to 8:05AM when in needs to re-start. So I calculate the number of seconds with the following def secs_ti

Re: [Tutor] Global presets ?

2004-12-04 Thread Dave S
Brian van den Broek wrote: Hi Dave, Kent, and all, I have a caution about the from Config import * idiom that Kent didn't mention. It can lead to namespace pollution, in that if you have a module 'foo' with a name 'bar' and you are witting a script which says from fo

Re: [Tutor] Accuracy of time.sleep()

2004-12-05 Thread Dave S
the way to go but Its kind of nice to keep it all Python if you know what I mean ;-) Dave ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor

[Tutor] Python structure advice ?

2004-12-15 Thread Dave S
7;pointers' which would be re-submitted when the function is called. I don't know which way to turn. With my code now running to a few hundred lines (Don't laugh this is BIG for me :-D ) I am going to have to make a structure decision and any suggestions would be appreciated. How would you approach it ? Dave ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python structure advice ?

2004-12-16 Thread Dave S
Dave S wrote: Im sorry to bang on about Python structure, but I do struggle with it, having in the past got into very bad habits with loads of BASIC where everything was global, and Forth, and hand coded 8031, 8051, 6502 I cant get my head round how you guys handle a modern structured

Re: [Tutor] Python structure advice ?

2004-12-17 Thread Dave S
Kent Johnson wrote: Dave S wrote: Dave S wrote: The 'remembering where is was' seems a continuous stumbling block for me. I have though of coding each module as a class but this seems like a cheat. I could declare copious globals, this seems messy, I could define each module as a th

Re: [Tutor] Python structure advice ?

2004-12-17 Thread Dave S
n being modules designed for reuse... It just makes life simpler! Ive tried to be hyper organized and added my dirs in /usr/lib/python2.3/site-packages/mypath.pth /home/dave/mygg/gg1.3/live_datad /home/dave/mygg/gg1.3/logger /home/dave/mygg/gg1.3/utils /home/dave/mygg/gg1.3/datacore /home/dave/mygg/g

Re: [Tutor] Python structure advice ?

2004-12-17 Thread Dave S
Jeff Shannon wrote: Dave S wrote: Kent Johnson wrote: Why do you say this is 'cheaty'? A class is basically a collection of data (state) and functions to operate on that state. Sorry for the delay, real world work got in the way ... Well I understand classes to be used when multiple

Re: [Tutor] Python structure advice ?

2004-12-17 Thread Dave S
x whenever you want :-) , its good to hear a range of views ! Dave ___ Tutor maillist - [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python structure advice ?

2004-12-17 Thread Dave S
Kent Johnson wrote: Dave S wrote: Separate modules is good. Separate directories for anything other than big programs (say 20 or more files?) is more hassle than its worth. The files are better kept in a single directory IMHO. The exception being modules designed for reuse... It just makes life

Re: [Tutor] Expanding a Python script to include a zcat and awk pre-process

2010-01-09 Thread Dave Angel
galaxywatc...@gmail.com wrote: After many more hours of reading and testing, I am still struggling to finish this simple script, which bear in mind, I already got my desired results by preprocessing with an awk one-liner. I am opening a zipped file properly, so I did make some progress, but

Re: [Tutor] what is the equivalent function to strtok() in c++

2010-01-10 Thread Dave Angel
sudhir prasad wrote: hi, what is the equivalent function to strtok() in c++, what i need to do is to divide a line into different strings and store them in different lists,and write them in to another file If your tokens are separated by whitespace, you can simply use a single call to split(

Re: [Tutor] Keeping a list of attributes of a certain type

2010-01-14 Thread Dave Angel
(You top-posted, which puts your two comments out of order. Now the solution comes before the problem statement) Guilherme P. de Freitas wrote: Ok, I got something that seems to work for me. Any comments are welcome. class Member(object): def __init__(self): pass class Body(obj

Re: [Tutor] Searching in a file

2010-01-15 Thread Dave Angel
Paul Melvin wrote: Hi, Thanks very much to all your suggestions, I am looking into the suggestions of Hugo and Alan. The file is not very big, only 700KB (~2 lines), which I think should be fine to be loaded into memory? I have two further questions though please, the lines are like this:

Re: [Tutor] Replacing the string in a file

2010-01-22 Thread Dave Angel
vanam wrote: Thanks for your mail. As you have suggested i have changed the mode to 'rw' but it is throwing up an error as below *** IOError: [Errno 22] invalid mode ('rw') or filename: 'data.txt' *** I am using python 2.6.4. But Script is managed to pass wit

Re: [Tutor] [File Input Module]Replacing string in a file

2010-01-28 Thread Dave Angel
vanam wrote: Hi all, As it was suggested before in the mailing list about the query regarding replacing string in the file, i have used the module File input for replacing the string in the file. For understanding and execution purpose, i have just included Python as a string in the file and wa

Re: [Tutor] hash value input

2010-01-30 Thread Dave Angel
spir wrote: On Fri, 29 Jan 2010 08:23:37 -0800 Emile van Sebille wrote: So, how does python do this? Start here... http://effbot.org/zone/python-hash.htm Great, thank you! From the above pointed page: For ordinary integers, the hash value is simply the integer itself

Re: [Tutor] parse text file

2010-02-02 Thread Dave Angel
Norman Khine wrote: thanks denis, On Tue, Feb 2, 2010 at 9:30 AM, spir wrote: On Mon, 1 Feb 2010 16:30:02 +0100 Norman Khine wrote: On Mon, Feb 1, 2010 at 1:19 PM, Kent Johnson wrote: On Mon, Feb 1, 2010 at 6:29 AM, Norman Khine wrote: thanks, what about the whi

Re: [Tutor] Question about importing

2010-02-02 Thread Dave Angel
Eike Welk wrote: On Tuesday February 2 2010 20:28:03 Grigor Kolev wrote: Can I use something like this #-- import sys sys.path.append("/home/user/other") import module #- Yes I think so. I

Re: [Tutor] SYS Long File Names?

2010-02-07 Thread Dave Angel
FT wrote: Hi! I was looking at the sys.argv(1) file name and it is the short 8 char name. How do you place it into the long file name format? I was reading music files and comparing the name to the directory listing and always comes back as not found because the name was shortened. So,

Re: [Tutor] NameError: global name 'celsius' is not defined (actually, solved)

2010-02-10 Thread Dave Angel
David wrote: Hello Wesley, thanks for your reply. I was surprised about the limited information too. Sadly (?), I can't reproduce the error any more... David On 10/02/10 11:13, wesley chun wrote: I just wrote this message, but after restarting ipython all worked fine. How is it to be exp

Re: [Tutor] A Stuborn Tab Problem in IDLE

2010-02-14 Thread Dave Angel
Wayne Watson wrote: I got to the dos command line facility and got to the file. I executed the program, and it failed with a syntax error. I can't copy it out of the window to paste here, but here's the code surrounding the problem: (arrow ==> points at the problem. The console code shows [ mi

Re: [Tutor] Getting caller name without the help of "sys._getframe(1).f_code.co_name" ?

2010-02-15 Thread Dave Angel
patrice laporte wrote: 2010/2/14 Luke Paireepinart I see why you would want the error messages but why is the default error message not enough, that is why I am curious, and typically introspection on objects is not necessary (for example, people often want to convert a string into a variab

Re: [Tutor] Problem with "input" in Python 3

2010-02-15 Thread Dave Angel
Peter Anderson wrote: Hi! I am trying to teach myself how to program in Python using Zelle's "Python Programming: An Introduction to Computer Science" (a very good text). At the same time I have decided to start with Python 3 (3.1.1). That means that I have to convert Zelle's example code to

Re: [Tutor] Input() is not working as expected in Python 3.1

2010-02-15 Thread Dave Angel
Yaraslau Shanhin wrote: Hello All, I am working with Python tutorial in wiki and one of the exercises is as follows: Ask the user for a string, and then for a number. Print out that string, that many times. (For example, if the string is hello and the number is 3 you should print out hellohello

Re: [Tutor] fast sampling with replacement

2010-02-21 Thread Dave Angel
Luke Paireepinart wrote: Can you explain what your function is doing and also post some test code to profile it? On Sat, Feb 20, 2010 at 10:22 AM, Andrew Fithian wrote: Hi tutor, I'm have a statistical bootstrapping script that is bottlenecking on a python function sample_with_replaceme

Re: [Tutor] Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-23 Thread Dave Angel
Wayne Watson wrote: A few days ago I posted a message titled ""Two" Card Monty. The problem I mentioned looks legitimate, and remains puzzling. I've probed this in a newsgroup, and no one has an explanation that fits. My claim is that if one creates a program in a folder that reads a file in

Re: [Tutor] Strange list behaviour in classes

2010-02-25 Thread Dave Angel
James Reynolds wrote: Thank you! I think I have working in the right direction. I have one more question related to this module. I had to move everything to a single module, but what I would like to do is have this class in a file by itself so I can call this from other modules. when it was in s

Re: [Tutor] Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-27 Thread Dave Angel
same behavior occurs using cmd prompt. Shortcuts have been in Windows for at least 20 years. But you still haven't given enough clues about what you're doing. I'll now head for Alan's reply. On 2/23/2010 5:35 PM, Dave Angel wrote: Wayne Watson wrote: A few days ago I poste

Re: [Tutor] Verifying My Troublesome Linkage Claim between Python and Win7

2010-02-28 Thread Dave Angel
Wayne Watson wrote: You tell us to "try this" and give a folder structure: Folder1 track1.py data1.txt data2.txt data3.txt Folder2 track1.py dset1.txt dset2.txt ... dset8.txt Maybe one simple test at a time will get better responses. Since you

Re: [Tutor] Verifying My Troublesome ...+Properties

2010-02-28 Thread Dave Angel
Wayne Watson wrote: (I sent the msg below to Steven and the list a moment ago, since msgs going to the list with attachments either don't post or take lots of time to post, I'm sending both of you this copy.) Steven, attached are three jpg files showing the properties of the two py files. The

Re: [Tutor] List comprehension possible with condition statements?

2010-03-03 Thread Dave Angel
Jojo Mwebaze wrote: Hi There, i would like to implement the following in lists assuming x = 3 y = 4 z = None i want to create a dynamic list such that mylist = [ x , y, z ] , if z in not None if z is None then mylist = [x,y] Anyhelp! cheers Jojo Are there any constraints on x an

Re: [Tutor] Bowing out

2010-03-03 Thread Dave Angel
Kent Johnson wrote: Hi all, After six years of tutor posts my interest and energy have waned and I'm ready to move on to something new. I'm planning to stop reading and contributing to the list. I have handed over list moderation duties to Alan Gauld and Wesley Chun. Thanks to everyone who cont

Re: [Tutor] sorting algorithm

2010-03-03 Thread Dave Angel
C.T. Matsumoto wrote: Hello, This is follow up on a question I had about algorithms. In the thread it was suggested I make my own sorting algorithm. Here are my results. #!/usr/bin/python def sort_(list_): for item1 in list_: pos1 = list_.index(item1) pos2 = pos1 + 1

Re: [Tutor] Encoding

2010-03-03 Thread Dave Angel
Giorgio wrote: Depends on your python version. If you use python 2.x, you have to use a u before the string: s = u'Hallo World' Ok. So, let's go back to my first question: s = u'Hallo World' is unicode in python 2.x -> ok s = 'Hallo World' how is encoded? Since it's a

Re: [Tutor] sorting algorithm

2010-03-03 Thread Dave Angel
(You forgot to do a Reply-All, so your message went to just me, rather than to me and the list ) C.T. Matsumoto wrote: Dave Angel wrote: C.T. Matsumoto wrote: Hello, This is follow up on a question I had about algorithms. In the thread it was suggested I make my own sorting algorithm

Re: [Tutor] lazy? vs not lazy? and yielding

2010-03-03 Thread Dave Angel
John wrote: Hi, I just read a few pages of tutorial on list comprehenion and generator expression. From what I gather the difference is "[ ]" and "( )" at the ends, better memory usage and the something the tutorial labeled as "lazy evaluation". So a generator 'yields'. But what is it yiel

Re: [Tutor] Encoding

2010-03-03 Thread Dave Angel
(Don't top-post. Put your response below whatever you're responding to, or at the bottom.) Giorgio wrote: Ok. So, how do you encode .py files? UTF-8? 2010/3/3 Dave Angel I personally use Komodo to edit my python source files, and tell it to use UTF8 encoding. Then I add

Re: [Tutor] object representation

2010-03-04 Thread Dave Angel
spir wrote: Hello, In python like in most languages, I guess, objects (at least composite ones -- I don't know about ints, for instance -- someone knows?) are internally represented as associative arrays. Python associative arrays are dicts, which in turn are implemented as hash tables. Corre

Re: [Tutor] Encoding

2010-03-04 Thread Dave Angel
Giorgio wrote: 2010/3/4 spir Ok,so you confirm that: s = u"ciao è ciao" will use the file specified encoding, and that t = "ciao è ciao" t = unicode(t) Will use, if not specified in the function, ASCII. It will ignore the encoding I specified on the top of the file. right? A literal

Re: [Tutor] object representation

2010-03-05 Thread Dave Angel
spir wrote: On Thu, 04 Mar 2010 09:22:52 -0500 Dave Angel wrote: Still, slots are important, because I suspect that's how built-ins are structured, to make the objects so small. Sure, one cannot alter their structure. Not even of a direct instance of : o = object()

Re: [Tutor] Encoding

2010-03-05 Thread Dave Angel
will use the default decoder. This is a logical example of what somebody said earlier on the thread -- decode any data to unicode as early as possible, and deal only with unicode strings in the program. Then, if necessary, encode them into whatever output form immediately before (or while) outputt

Re: [Tutor] Bowing out

2010-03-05 Thread Dave Kuhlman
re your ability and knowledge about Python. And, I appreciate the huge amount of effort you've put into helping us. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Encoding

2010-03-05 Thread Dave Angel
Giorgio wrote: 2010/3/5 Dave Angel In other words, you don't understand my paragraph above. Maybe. But please don't be angry. I'm here to learn, and as i've run into a very difficult concept I want to fully undestand it. I'm not angry, and I'm sor

Re: [Tutor] Encoding

2010-03-07 Thread Dave Angel
Giorgio wrote: 2010/3/7 spir One more question: Amazon SimpleDB only accepts UTF8. So, let's say i have to put into an image file: Do you mean a binary file with image data, such as a jpeg? In that case, an emphatic - NO. not even close. filestream = file.read() filetoput = filestr

Re: [Tutor] Encoding

2010-03-07 Thread Dave Angel
Giorgio wrote: 2010/3/7 Dave Angel Those two lines don't make any sense by themselves. Show us some context, and we can more sensibly comment on them. And try not to use names that hide built-in keywords, or Python stdlib names. Hi Dave, I'm considering Amazon Simp

Re: [Tutor] Communicate between a thread and the main program

2010-03-08 Thread Dave Angel
Plato P.B. wrote: Hi all, I have created a script in which i need to implement the communication between the main program and a thread. The thread looks for any newly created files in a particular directory. It will be stored in a variable in the thread function. I want to get that name from the

Re: [Tutor] sorting algorithm

2010-03-11 Thread Dave Angel
C.T. Matsumoto wrote: Dave Angel wrote: (You forgot to do a Reply-All, so your message went to just me, rather than to me and the list ) C.T. Matsumoto wrote: Dave Angel wrote: C.T. Matsumoto wrote: Hello, This is follow up on a question I had about algorithms. In the thread it was

Re: [Tutor] sorting algorithm

2010-03-12 Thread Dave Angel
C.T. Matsumoto wrote: I've change the code and I think I have what you were talking about. def mysort(list_): for i in xrange(0, len(list_)): pos = i for j in xrange(pos+1, len(list_)): if list_[i] > list_[j]: pos = j list_[i]

Re: [Tutor] Efficiency and speed

2010-03-20 Thread Dave Angel
(Please don't top-post. It ruins the context for anyone else trying to follow it. Post your remarks at the end, or immediately after whatever you're commenting on.) James Reynolds wrote: Here's another idea I had. I thought this would be slower than then the previous algorithm because it has

Re: [Tutor] python magazine

2010-03-27 Thread Dave Angel
Lowell Tackett wrote: >From the virtual desk of Lowell Tackett --- On Fri, 3/26/10, Benno Lang wrote: From: Benno Lang Subject: Re: [Tutor] python magazine To: "Lowell Tackett" Cc: tutor@python.org, "Bala subramanian" Date: Friday, March 26, 2010, 8:38 PM On 27 March 2010 00:33, Lowel

Re: [Tutor] inter-module global variable

2010-03-28 Thread Dave Angel
spir # wrote: Hello, I have a main module importing other modules and defining a top-level variable, call it 'w' [1]. I naively thought that the code from an imported module, when called from main, would know about w, but I have name errors. The initial trial looks as follows (this is just a

Re: [Tutor] python magazine

2010-03-28 Thread Dave Angel
Lowell Tackett wrote: >From the virtual desk of Lowell Tackett --- On Sat, 3/27/10, Dave Angel wrote: From: Dave Angel Subject: Re: [Tutor] python magazine To: "Lowell Tackett" Cc: "Benno Lang" , tutor@python.org Date: Saturday, March 27, 2010, 6:12 AM

Re: [Tutor] inter-module global variable

2010-03-28 Thread Dave Angel
spir # wrote: On Sun, 28 Mar 2010 21:50:46 +1100 Steven D'Aprano wrote: On Sun, 28 Mar 2010 08:31:57 pm spir ☣ wrote: I'm going to assume you really want a single global value, and that you won't regret that assumption later. We talked at length about how to access that global from

Re: [Tutor] commands

2010-03-28 Thread Dave Angel
Shurui Liu (Aaron Liu) wrote: # Translate wrong British words #Create an empty file print "\nReading characters from the file." raw_input("Press enter then we can move on:") text_file = open("storyBrit.txt", "r+") whole_thing = text_file.read() print whole_thing raw_input("Press enter then we ca

Re: [Tutor] what's wrong in my command?

2010-04-01 Thread Dave Angel
Shurui Liu (Aaron Liu) wrote: # geek_translator3.py # Pickle import pickle This is where you told it to load import.py. Normally, that just quietly loads the standard module included with your system. When I run it, the system gave me the feedback below: Traceback (most recent call las

Re: [Tutor] what's wrong in my command?

2010-04-01 Thread Dave Angel
aid pickle.py, not import.py. When you import pickle, you're tell it to find and load pickle.py. That's python source code, and it will generally import other modules. I was suspecting module.py. But you should start by looking at line 13 of pickle.py On Thu, Apr 1, 2010 at 5:45 AM,

Re: [Tutor] constructor

2010-04-04 Thread Dave Angel
Shurui Liu (Aaron Liu) wrote: I am studying about how to create a constructor in a Python program, I don't really understand why the program print out "A new critter has been born!" and "Hi. I'm an instance of class Critter." twice. I guess is because "crit1 = Critter() crit2 = Critter()"

Re: [Tutor] Matching zipcode in address file

2010-04-04 Thread Dave Angel
Alan Gauld wrote: "TGW" wrote I go the program functioning with lines = [line for line in infile if line[149:154] not in match_zips] But this matches records that do NOT match zipcodes. How do I get this running so that it matches zips? Take out the word 'not' from the comprehension? T

Re: [Tutor] Extracting lines in a file

2010-04-06 Thread Dave Angel
ranjan das wrote: Hi, I am new to python, and specially to file handling. I need to write a program which reads a unique string in a file and corresponding to the unique string, extracts/reads the n-th line (from the line in which the unique string occurs). I say 'n-th line' as I seek a gener

Re: [Tutor] Sequences of letter

2010-04-12 Thread Dave Angel
Or more readably: from string import lowercase as letters for c1 in letters: for c2 in letters: for c3 in letters: print c1+c2+c3 Yashwin Kanchan wrote: Hi Juan Hope you have got the correct picture now... I just wanted to show you another way of doing the above th

Re: [Tutor] Move all files to top-level directory

2010-04-12 Thread Dave Angel
Dotan Cohen wrote: On 12 April 2010 20:12, Sander Sweers wrote: On 12 April 2010 18:28, Dotan Cohen wrote: However, it fails like this: $ ./moveUp.py Traceback (most recent call last): File "./moveUp.py", line 8, in os.rename(f, currentDir) TypeError: coercing to Unicode: need st

Re: [Tutor] Move all files to top-level directory

2010-04-12 Thread Dave Angel
Dotan Cohen wrote: All right, I have gotten quite a bit closer, but Python is now complaining about the directory not being empty: ✈dcl:test$ cat moveUp.py #!/usr/bin/python # -*- coding: utf-8 -*- import os currentDir =s.getcwd() filesList =s.walk(currentDir) for root, folder, file in filesL

Re: [Tutor] Move all files to top-level directory

2010-04-13 Thread Dave Angel
Dotan Cohen wrote: Here is the revised version: #!/usr/bin/python # -*- coding: utf-8 -*- import os currentDir = os.getcwd() i = 1 filesList = os.walk(currentDir) for rootDirs, folders, files in filesList: Actual the first item in the tuple (returned by os.walk) is singular (a string), so I

Re: [Tutor] Loop comparison

2010-04-16 Thread Dave Angel
Christian Witts wrote: Ark wrote: Hi everyone. A friend of mine suggested me to do the next experiment in python and Java. It's a simple program to sum all the numbers from 0 to 10. result = i = 0 while i < 10: result += i i += 1 print result The time for this calc

Re: [Tutor] QUESTION REGARDING STATUS OF MY SUBSCRIPTION FW: Auto-response for your message to the "Tutor" mailing list

2010-04-16 Thread Dave Angel
Peter Meagher wrote: GREETINGS, THIS EMAIL WOULD INDICATE THAT I AM ON THE SUBSCRIPTION LIST. HOWEVER, I GOT ANOTHER EMAIL, THAT CAME IN AT PRECISELY THE SAME TIME AS THE ORIGINAL MESSAGE THAT I AM FORWARDING YOU. THAT INDICATES THAT THERE WAS AN ISSUE ADDING ME TO THE LIST. I'VE PASTED IT IN T

Re: [Tutor] Loop comparison

2010-04-16 Thread Dave Angel
ALAN GAULD wrote: The precalculation optimisations are taking place. If you pass it an argument to use for the upper limit of the sequence the calculation time shoots up. I'm still confused about when the addition takes place. Surely the compiler has to do the addition, so it should

Re: [Tutor] Loop comparison

2010-04-17 Thread Dave Angel
Alan Gauld wrote: "Lie Ryan" wrote A friend of mine suggested me to do the next experiment in python and Java. It's a simple program to sum all the numbers from 0 to 10. result = i = 0 while i < 10: result += i i += 1 print result Are you sure you're not causing Ja

Re: [Tutor] Python root.

2010-04-18 Thread Dave Angel
Aidas wrote: Hello. In here http://mail.python.org/pipermail/tutor/2001-February/003385.html You had written how to ger root in python. The way is: "from math import sqrtprint sqrt( 49 )". I noticed that if I write just "print sqrt(49)" I get nothing. I don't get "nothing," I get an error

Re: [Tutor] the binary math "wall"

2010-04-20 Thread Dave Angel
Lowell Tackett wrote: I'm running headlong into the dilemma of binary math representation, with game-ending consequences, e.g.: 0.15 0.14999 Obviously, any attempts to manipulate this value, under the misguided assumption that it is truly "0.15" are ill-advised, with

Re: [Tutor] the binary math "wall"

2010-04-21 Thread Dave Angel
Lowell Tackett wrote: --- On Tue, 4/20/10, Steven D'Aprano wrote: From: Steven D'Aprano The simplest, roughest way to fix these sorts of problems (at the risk of creating *other* problems!) is to hit them with a hammer: round(18.15*100) == 1815 True In

Re: [Tutor] the binary math "wall"

2010-04-21 Thread Dave Angel
Lowell Tackett wrote: From the virtual desk of Lowell Tackett --- On Wed, 4/21/10, Dave Angel wrote: From: Dave Angel Subject: Re: [Tutor] the binary math "wall" To: "Lowell Tackett" Cc: tutor@python.org, "Steven D'Aprano" Date: Wednesday, April

Re: [Tutor] the binary math "wall"

2010-04-21 Thread Dave Angel
Steven D'Aprano wrote: On Thu, 22 Apr 2010 01:37:35 am Lowell Tackett wrote: Were I to accumulate many of these "legs" into perhaps a 15 mile traverse-accumulating little computer errors along the way-the end result could be catastrophically wrong. YES!!! And just by being aware of th

Re: [Tutor] sys.path and the path order

2010-04-23 Thread Dave Angel
Garry Willgoose wrote: My question is so simple I'm surprised I can't find an answer somewhere. I'm interested if I can rely on the order of the directories in the sys.path list. When I'm running a file from the comand line like python tellusim.py The string in entry sys.path[0] appears to b

Re: [Tutor] Hi everybody stuck on some error need help please thank you!!

2010-04-24 Thread Dave Angel
(Don't top-post. Either put your remarks immediately after the part they reference, or at the end of the message. Otherwise, everything's thoroughly out of order.) Marco Rompré wrote: I tried to enter model = Modele (nom_fichier) but it still does not work. You didn't define the global no

Re: [Tutor] Binary search question

2010-04-25 Thread Dave Angel
Lie Ryan wrote: On 04/24/10 23:39, Robert Berman wrote: -Original Message- From: tutor-bounces+bermanrl=cfl.rr@python.org [mailto:tutor- bounces+bermanrl=cfl.rr@python.org] On Behalf Of Alan Gauld Sent: Friday, April 23, 2010 7:41 PM To: tutor@python.org Subject: Re: [Tutor] B

Re: [Tutor] For loop breaking string methods

2010-04-26 Thread Dave Angel
C M Caine wrote: Thank you for the clarification, bob. For any future readers of this thread I include this link[1] to effbot's guide on lists, which I probably should have already read. My intention now is to modify list contents in the following fashion: for index, value in enumerate(L):

Re: [Tutor] Is the difference in outputs with different size input lists due to limits on memory with PYTHON?

2010-05-06 Thread Dave Angel
Art Kendall wrote: I am running Windows 7 64bit Home premium. with quad cpus and 8G memory. I am using Python 2.6.2. I have all the Federalist Papers concatenated into one .txt file. Which is how big? Currently you (unnecessarily) load the entire thing into memory with readlines(). And the

Re: [Tutor] Is the difference in outputs with different size input lists due to limits on memory with PYTHON?

2010-05-06 Thread Dave Angel
Art Kendall wrote: On 5/6/2010 11:14 AM, Dave Angel wrote: Art Kendall wrote: I am running Windows 7 64bit Home premium. with quad cpus and 8G memory. I am using Python 2.6.2. I have all the Federalist Papers concatenated into one .txt file. Which is how big? Currently you

Re: [Tutor] Is the difference in outputs with different size input lists due to limits on memory with PYTHON?

2010-05-06 Thread Dave Angel
Art Kendall wrote: On 5/6/2010 1:51 PM, Dave Angel wrote: Art Kendall wrote: On 5/6/2010 11:14 AM, Dave Angel wrote: Art Kendall wrote: I am running Windows 7 64bit Home premium. with quad cpus and 8G memory. I am using Python 2.6.2. I have all the Federalist Papers concatenated into

Re: [Tutor] Is the difference in outputs with different size input lists due to limits on memory with PYTHON?

2010-05-07 Thread Dave Angel
Art Kendall wrote: On 5/6/2010 8:52 PM, Dave Angel wrote: I got my own copy of the papers, at http://thomas.loc.gov/home/histdox/fedpaper.txt I copied your code, and added logic to it to initialize termlist from the actual file. And it does complete the output file at 83 lines

Re: [Tutor] (no subject)

2010-05-11 Thread Dave Angel
Sivapathasuntha Aruliah wrote: Hi I am learning Python. When I tried to run any of the program for example csv2html1_ans.py it displays the following message. This error is coming on both Python24 & Python 31. That is whether i give the any one of the following command COMMAND GIVEN 1.C:\pyt

Re: [Tutor] Help required to count no of lines that are until 1000 characters

2010-05-11 Thread Dave Angel
ramya natarajan wrote: Hello, I am very beginner to programming, I got task to Write a loop that reads each line of a file and counts the number of lines that are read until the total length of the lines is 1,000 characters. I have to read lines from files exactly upto 1000 characters. Her

  1   2   3   4   5   6   7   8   9   10   >