Re: [Tutor] the binary math "wall"

2010-04-20 Thread Jerry Hill
On Tue, Apr 20, 2010 at 12:58 PM, Lowell Tackett wrote: > Any of Python's help-aids that I apply to sort things out, such as formatting > (%), or modules like "decimal" do nothing more than "powder up" the display > for visual consumption (turning it into a string).  The underlying float > valu

Re: [Tutor] smtplib help required

2010-04-23 Thread Jerry Hill
On Fri, Apr 23, 2010 at 6:41 PM, James Chapman wrote: > Hi there gurus and everyone else. This is my first post to this group, and > I'm turning here because I'm stumped and search engines are not helping. > I've used smtplib for a few things already and while wanting to use it again > today, I'm

Re: [Tutor] Using Regex to produce text

2010-04-28 Thread Jerry Hill
On Wed, Apr 28, 2010 at 2:27 AM, wrote: > Is there an way of using the regex patterns to produce text, instead of > matching it? There have been some previous discussions about generating all of the possible matches for a given regular expressions. I believe these are the first messages in a c

Re: [Tutor] Problems installing

2010-06-30 Thread Jerry Hill
On Wed, Jun 30, 2010 at 1:35 AM, Andrew Martin wrote: > I just downloaded Python 2.6.5 onto my windows vista laptop. I am > attempting to install "escript version 3: Solution of Partial Differential > Equations (PDE) using Finite Elements (FEM)." I downloaded the files and > manually placed them i

Re: [Tutor] A unicode print question

2010-07-30 Thread Jerry Hill
On Fri, Jul 30, 2010 at 1:33 PM, Joel Goldstick wrote: > I was reading this: http://diveintopython.org/xml_processing/unicode.html > > and tried the exercise: > > But oddly enough, when I typed it into my python shell I did NOT get the > UnicodeError, and I wonder why not: > I believe that pyth

Re: [Tutor] access class through indexing?

2010-08-04 Thread Jerry Hill
On Wed, Aug 4, 2010 at 4:17 PM, Alex Hall wrote: > Hi all, > Further to my questions about overriding builtin methods earlier, how > would I make a class able to be accessed and changed using index > notation? For example, take the following: > deck=CardPile(52) #creates a new deck of cards > pri

Re: [Tutor] access class through indexing?

2010-08-04 Thread Jerry Hill
On Wed, Aug 4, 2010 at 5:28 PM, Alex Hall wrote: > Here is my init, not half as pretty as yours, but it should work. > Maybe this will explain the problem. > > def __init__(self, size, cards=None, fill=False): > #creates a pile of cards. If "fill"==true, it will auto-fill the > pile starting fro

Re: [Tutor] Questions regarding strings

2010-08-09 Thread Jerry Hill
On Sun, Aug 8, 2010 at 1:04 PM, Daniel wrote: > > Can someone please explain this to me? Thank you so much and I wish everyone > a great day! Beyond what Hugo mentioned in his message, take a look at the tutorial: http://docs.python.org/tutorial/introduction.html#strings I don't see a way to di

Re: [Tutor] Elementtree and pretty printing in Python 2.7

2010-08-22 Thread Jerry Hill
On Fri, Aug 20, 2010 at 3:49 AM, Knacktus wrote: > Hi guys, > > I'm using Python 2.7 and the ElementTree standard-lib to write some xml. > > My output xml has no line breaks! So, it looks like that: > > > > instead of something like this: > > >     > > > I'm aware of lxml which seems to have a

Re: [Tutor] function with multiple checks

2010-09-27 Thread Jerry Hill
On Mon, Sep 27, 2010 at 11:09 AM, Tim Miller wrote: > I've got a small function that I'm using to check whether a password is of a > certain length and contains mixed case, numbers and punctuation. > > Originally I was using multiple "if re.search" for the patterns but it > looked terrible so I've

Re: [Tutor] 'pydoc' is not recognized as an internal or external command, ...

2010-11-12 Thread Jerry Hill
On Fri, Nov 12, 2010 at 6:44 PM, Steven D'Aprano wrote: > Use the Find File command, and see if you can find something called "pydoc". > You may need to call the full path to the program, e.g.: > > C:\My Documents\path\to\program\pydoc raw_input On my windows PC, it's c:\Python31\Lib\pydoc.py So

Re: [Tutor] New Issues with REGEX Greediness:

2009-08-03 Thread Jerry Hill
On Sun, Aug 2, 2009 at 2:55 PM, gpo wrote: > > Python: > line='>Checking Privilege for UserId: > {874BE70A-194B-DE11-BE5C-000C297901A5}, PrivilegeId: {prvReadSdkMessage}. > Returned hr = 0' > (re.search('(\w+)\:.+.{8}-.{4}-.{4}-.{4}-.{12}',line)).group(0) > RESULT > 'UserId: {874BE70A-194B-DE11-BE5

Re: [Tutor] Simple regex replacement match (converting from Perl)

2009-09-04 Thread Jerry Hill
On Fri, Sep 4, 2009 at 1:34 PM, GoodPotatoes wrote: > I simply want to remark out all non-word characters read from a line. > > Line: > Q*bert says "#...@!$%  " > > in Perl > #match each non-word character, add "\" before it, globally. > > $_=s/(\W)/\\$1/g; > > output: > Q\*bert\ says\ \"\...@\!\$\

Re: [Tutor] Which version to start with?

2009-10-06 Thread Jerry Hill
On Tue, Oct 6, 2009 at 8:59 AM, Ken G. wrote: > I am just starting on Python 2.6.2 on Ubuntu 9.04 and I am slightly confused > with the numerous tutorials and books available for learning the language. > Is there any good recommendation for a good but easy tutorial on the > Internet to learn Pytho

Re: [Tutor] Curses - What does it do and why is it called this?

2009-10-22 Thread Jerry Hill
On Tue, Oct 13, 2009 at 3:11 AM, Katt wrote: > Now I understand.  Makes sense.  If "Curses" is for UNIX what would I use on > a Windows XP system using Python 2.6.2? I like the Console package: http://effbot.org/zone/console-index.htm -- Jerry ___ Tut

Re: [Tutor] Still having trouble with my game of life algorithm

2007-05-25 Thread Jerry Hill
On 5/25/07, Matt Smith <[EMAIL PROTECTED]> wrote: > def update_matrix(matrix): > matrix_updated = matrix That line assigns the name matrix_updated to the same list-of-lists as matrix. Since lists are mutable objects, changing matrix_updated is also changing matrix. What you need is to bind m

Re: [Tutor] creating a buffer object from a file ?

2007-05-31 Thread Jerry Hill
On 5/31/07, Iyer <[EMAIL PROTECTED]> wrote: > I think this got lost among the threads: I think it got lost because you haven't given us enough information to answer your question. > in reality what is a buffer object used for ? reading > a file itself creates a string as in itself, We don't know

Re: [Tutor] back on bytes

2007-07-06 Thread Jerry Hill
On 7/6/07, shawn bright <[EMAIL PROTECTED]> wrote: > i have a number 12480 > i have a low byte of 192 and a high byte of 176 Maybe I'm being dense, but that doesn't make any sense at all to me. The high byte of 12480 is 48, and the low byte is 192, isn't it? Because (48 * 256) + 192 = 12480? In y

Re: [Tutor] How to determine if every character in one string is in another string?

2007-07-20 Thread Jerry Hill
On 7/20/07, Terry Carroll <[EMAIL PROTECTED]> wrote: > Is there a straightforward way to find out if all characters in one string > are present in a second string? I like this one: all(char in string.printable for char in testString) >>> testString = "qwerty\buiop" >>> all(char in string.printabl

Re: [Tutor] How to determine if every character in one string is inanother string?

2007-07-22 Thread Jerry Hill
On 7/21/07, Alan Gauld <[EMAIL PROTECTED]> wrote: > > all(char in string.printable for char in testString) > > What is all? > Is that a 2.5 thing (I'm still on 2.4 here) Yes, it's a 2.5 thing. All returns true if all of the elements of an iterable are true. According to the docs, it is the equiv

Re: [Tutor] Quick question

2007-09-21 Thread Jerry Hill
On 9/21/07, Tino Dai <[EMAIL PROTECTED]> wrote: > Is there a more pythonic way of doing this: > > if queuePacket.has_key('procSeq') and \ > queuePacket.has_key('opacSeq') and \ > queuePacket.has_key('keySeq') and \ > len(queuePacket['procSeq']) == 0 and \ > len(queuePacket['opacSeq']) ==

Re: [Tutor] how to accept an integer?

2007-12-05 Thread Jerry Hill
On Dec 5, 2007 4:01 PM, Mahesh N <[EMAIL PROTECTED]> wrote: > I dun understand the mistake. My aim is to accept an integer number. The > python lookup in IDLE asks for a string object but the interpreter returns > with the following error message. Some one pls explain. > Thank You > > PS : I under

Re: [Tutor] how to accept an integer?

2007-12-05 Thread Jerry Hill
On Dec 5, 2007 4:46 PM, Bryan Fodness <[EMAIL PROTECTED]> wrote: > On Dec 5, 2007 4:16 PM, Jerry Hill <[EMAIL PROTECTED]> wrote: > > speed = int(raw_input(prompt)) > > > Is this how ALL known integers should be input? I don't think I understand the question.

Re: [Tutor] Translate this VB.NET code into Python for me?

2008-03-04 Thread Jerry Hill
On Tue, Mar 4, 2008 at 8:05 AM, Dick Moores <[EMAIL PROTECTED]> wrote: > By the second chapter I've begun to suspect that GUIs aside, Python > is a lot simpler to write. Could someone prove that to me by > translating the code I've pasted at > (from p

Re: [Tutor] Function for converting ints from base10 to base2?

2007-02-21 Thread Jerry Hill
On 2/21/07, Dick Moores <[EMAIL PROTECTED]> wrote: > But there's syntax(?) there I've never seen before. "['','-'][n<0]". > I see it works: > > >>> n = -6 > >>> ['','-'][n<0] > '-' > >>> n = 98 > >>> ['','-'][n<0] > '' > > What's this called? I'd like to look it up. ['', '-'] is a list with tw

Re: [Tutor] FW: isinstance -> instance

2007-02-26 Thread Jerry Hill
On 2/26/07, Bernard Lebel <[EMAIL PROTECTED]> wrote: > That's fine, but that tells me that 'a' is an instance of 'A'. > It doesn't, however, tell me if 'a' is an instance or the actual class object. It doesn't? >>> class A: pass >>> a = A() >>> isinstance(a, A) True >>> isinstance(A, A)

Re: [Tutor] Matching string

2007-02-27 Thread Jerry Hill
On 2/27/07, govind goyal <[EMAIL PROTECTED]> wrote: > Hello, > > I want to use a pattern matcing (regular expression) inside "if loop" such > that if it will find "MBytes" and "Mbits/sec" both at a time regardless of > there position in a particular string ,then only it executes code inside "if >

Re: [Tutor] howto call DOM with python

2007-02-28 Thread Jerry Hill
On 2/28/07, Ismael Farfán Estrada <[EMAIL PROTECTED]> wrote: > I was wondering wheter someone knows how to use python to write > a client-side scripts like if it were java I don't think this is possible, at least without creating a custom-compiled version of Firefox. There's a little bit of discu

Re: [Tutor] Regular expressions - Ignoring linefeeds

2007-03-02 Thread Jerry Hill
On 3/2/07, doug shawhan <[EMAIL PROTECTED]> wrote: > I've been looking through various sites, but cannot find the magic button > that allows me to match a string with linefeeds > I'd rather not strip out the linefeeds, then stick them back in. :-) Try this: >>> s = '''Good gravy! Hi there. I'm so

Re: [Tutor] White spaces in a path (from a string variable) and os.popen on Windows

2007-03-08 Thread Jerry Hill
On 3/8/07, learner404 <[EMAIL PROTECTED]> wrote: > When I know exactly the path in advance I use a raw string r' ' and I add > double quotes where necessary to avoid the white spaces syndrome. But I > don't see how to do this "easily" when my path is a string variable given by > my GUI (like C:\Doc

Re: [Tutor] Finding the minimum value in a multidimensional array

2007-03-13 Thread Jerry Hill
On 3/13/07, Geoframer <[EMAIL PROTECTED]> wrote: > I don't see a solution here... It is not conclusive on what's the minimum > for an array. > > ln [1]: import numpy > In [2]: a = > numpy.array([[1,2,3,0],[2,3,4,5],[6,5,4,3],[-1,2,-4,5]]) Well, what exactly is it that you'd like the answer to be?

Re: [Tutor] fine in interpreter, hangs in batch

2007-03-16 Thread Jerry Hill
On 3/16/07, Switanek, Nick <[EMAIL PROTECTED]> wrote: > After creating a list of words ('wordlist'), I can run the following > code in the interactive window of PythonWin in about ten seconds. If I > run the script containing the code, the script seems to hang on the > loop. I'd be grateful for hel

Re: [Tutor] fine in interpreter, hangs in batch

2007-03-19 Thread Jerry Hill
On 3/19/07, Switanek, Nick <[EMAIL PROTECTED]> wrote: > Thanks very much for your help. > > It appears that the step that is taking a long time, and that therefore > makes me think that the script is somehow broken, is creating a > dictionary of frequencies from the list of ngrams. To do this, I've

Re: [Tutor] Writing dictionaries to a file

2008-04-07 Thread Jerry Hill
On Mon, Apr 7, 2008 at 1:09 PM, Jerrold Prothero <[EMAIL PROTECTED]> wrote: > Relevant Python 2.5 documentation sections are 9.1.1 and 9.1.4. My > question boils down to this: what does writerows want as an argument > for a dictionary? A list of dictionaries. One dictionary for each row you would

Re: [Tutor] Doubts about Pylint

2008-04-09 Thread Jerry Hill
On Wed, Apr 9, 2008 at 12:43 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > I'd never used Pylint until yesterday, when I discovered that Ulipad > had a Pylint plugin that enabled me to run Pylint on scripts within > Ulipad. But I'm wondering about some of the results. I noticed that > it was comp

Re: [Tutor] List comprehensions

2008-04-09 Thread Jerry Hill
On Wed, Apr 9, 2008 at 7:12 AM, Dinesh B Vadhia <[EMAIL PROTECTED]> wrote: > I want to replace the for loop with a List Comrehension (or whatever) to > improve performance (as the data list will be >10,000]. At each stage of > the for loop I want to print the result ie. List comprehensions are fo

Re: [Tutor] List comprehensions

2008-04-09 Thread Jerry Hill
On Wed, Apr 9, 2008 at 4:15 PM, Dinesh B Vadhia <[EMAIL PROTECTED]> wrote: > Sorry, let's start again. This version really isn't any more helpful than the first one. I know you corrected the sample code, but you haven't addressed any of the fundamental questions that Kent or I asked. > I want to

Re: [Tutor] List comprehensions

2008-04-09 Thread Jerry Hill
On Wed, Apr 9, 2008 at 4:48 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > You could use > [ sys.stdout.write(some operation on item) for item in data ] > > but I consider this bad style and I seriously doubt you will see any > difference in performance. This really isn't a good idea. It will

Re: [Tutor] When to use __new__ vs. __init__ ?

2008-04-18 Thread Jerry Hill
On Fri, Apr 18, 2008 at 12:08 PM, <[EMAIL PROTECTED]> wrote: > Any guidelines on when to use __new__ vs. __init__ when sub-classing? Use __new__ when you need to control the creation of a new instance. Use __init__ when you need to control initialization of a new instance. __new__ is the first s

Re: [Tutor] python -v command

2008-05-02 Thread Jerry Hill
On Fri, May 2, 2008 at 11:33 AM, Stephanie <[EMAIL PROTECTED]> wrote: > Hi, > I'm at a very beginning level of Python knowledge, but I use several Python > programs via the Macintosh Unix Terminal. I was trying to quickly see which > version of Python I am running and typed in the command "python

Re: [Tutor] Regular expressions...

2008-05-02 Thread Jerry Hill
On Fri, May 2, 2008 at 12:08 PM, Spencer Parker <[EMAIL PROTECTED]> wrote: > I need to use a regular expression to get a couple of items for my python > script. So far the script is running an 'ls' command to get a few items > that I need Why do you need to use regular expressions? This problem

Re: [Tutor] Supported platform

2008-05-21 Thread Jerry Hill
On Wed, May 21, 2008 at 2:11 PM, Amit Kumar <[EMAIL PROTECTED]> wrote: > Can I get list of supported platform by python? > > can I install python on AS/400 and HP-Unix? I don't know of any sort of official list of supported platforms. Activestate claims to have a python distribution for HPUX: htt

Re: [Tutor] I need to learn more about sorting!

2008-06-23 Thread Jerry Hill
On Mon, Jun 23, 2008 at 4:06 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > I needed to sort a list of 2-element tuples by their 2nd elements. I > couldn't see a ready-made function around to do this, so I rolled my own: ... > colors = [('khaki4', (139, 134, 78)), ('antiquewhite', (250, 235, 215)

Re: [Tutor] s[len(s):len(s)] = [x] ??

2008-06-30 Thread Jerry Hill
On Mon, Jun 30, 2008 at 4:47 PM, Dick Moores <[EMAIL PROTECTED]> wrote: > Show me a better way? You can do it with slice assignment too: >>> a = [1, 2, 3, 4] >>> a[1:3] = [[7, 8]] >>> a [1, [7, 8], 4] Now, which way is better? The answer depends on context. The best way to write it is in the ma

Re: [Tutor] search path

2008-07-07 Thread Jerry Hill
On Sun, Jul 6, 2008 at 3:47 PM, Robert Johansson <[EMAIL PROTECTED]> wrote: > Running the script file she gets error messages claiming that the textfiles > cannot be found when they are to be opened with > fileid=file('textfilename.txt','r') even though the same thing works fine on > my system. Any

Re: [Tutor] accessing string in list

2008-07-15 Thread Jerry Hill
On Tue, Jul 15, 2008 at 10:55 AM, Bryan Fodness <[EMAIL PROTECTED]> wrote: > I have a list of labels for a data file, > > test = ['depth', '4', '6', '10', '15', '20', '30', '40', 'angle'] > > I would like to get the string of the first value that is greater than a > known value and the previous str

Re: [Tutor] Question on how to do something.

2008-07-18 Thread Jerry Hill
On Thu, Jul 17, 2008 at 6:39 PM, Mitchell Nguyen <[EMAIL PROTECTED]> wrote: > Hello. I'm new to Python and I was wondering how to read all the files in a > folder. I used this program or command for single files. > > And if possible, is there a way to make it so that it waits at the end of > each f

Re: [Tutor] where to report a bug?

2008-07-25 Thread Jerry Hill
On Fri, Jul 25, 2008 at 10:04 AM, Rick Pasotto <[EMAIL PROTECTED]> wrote: > I have a script that works fine on my linux machine but bombs out when > run under windows using the exact same data files. The script downloads > a file then unzips it and then scans the resulting file for certain > record

Re: [Tutor] Python Docs (Was: Reformatting phone number)

2008-08-21 Thread Jerry Hill
On Thu, Aug 21, 2008 at 12:01 PM, Dotan Cohen <[EMAIL PROTECTED]> wrote: > 2008/8/21 Kent Johnson <[EMAIL PROTECTED]>: >> Chapters 2 and 3 of the library reference are highly recommended. >> http://docs.python.org/lib/lib.html > > Let's start from there. I need the startswith() function, but I do n

Re: [Tutor] list slice

2008-09-15 Thread Jerry Hill
On Mon, Sep 15, 2008 at 10:56 AM, Norman Khine <[EMAIL PROTECTED]> wrote: > Hello, > I have this code: > > topics = object.parent.get_topics() >for i, topic in enumerate(topics): >all_previous_topics = topics[:i] >print all_previous_topics > > where topics returns a

Re: [Tutor] Sort Output

2008-09-17 Thread Jerry Hill
On Wed, Sep 17, 2008 at 3:30 PM, Wayne Watson <[EMAIL PROTECTED]> wrote: > I'm using Python 2.4 in Win XP. I was surprised to find the result below. > a =[4,2,5,8] b = a This binds the name "b" to the same object that "a" is bound to. a.sort() a > [2, 4, 5, 8] b > [2, 4,

Re: [Tutor] image processing

2008-09-23 Thread Jerry Hill
On Tue, Sep 23, 2008 at 5:38 PM, jeremiah <[EMAIL PROTECTED]> wrote: > I'm trying to do simple image manipulation but am getting an error. any > ideas what i am doing wrong here? > > file=open("./"+name,"w") > pic=Image.open(file) You're opening the file for "w"riting, then asking PIL to read it.

Re: [Tutor] re.compile concatenating two searh words

2008-09-29 Thread Jerry Hill
On Mon, Sep 29, 2008 at 6:19 PM, Srinivas Iyyer <[EMAIL PROTECTED]> wrote: > Hi Tutors, > I have a list with elements as strings. I want to search if any of these > element strings has two words of my interest. How can I ask re.compile to > look for both words. > > my words are 'good' and 'bad'.

Re: [Tutor] cx_oracle module problems

2008-10-07 Thread Jerry Hill
On Tue, Oct 7, 2008 at 2:46 PM, jeremiah <[EMAIL PROTECTED]> wrote: > I've downloaded the cx_oracle source module for python, howerver every > time i try to build it, it keeps on failing. I've been unable to find a > port for Ubuntu. Is there one? Anyone know how to get this properly > installed? >

Re: [Tutor] appending to a utf-16 encoded text file

2008-10-21 Thread Jerry Hill
On Tue, Oct 21, 2008 at 9:52 AM, Tim Brown <[EMAIL PROTECTED]> wrote: > Hi, > I'm trying to create and append unicode strings to a utf-16 text file. > The best I could come up with was to use codecs.open() with an > encoding of 'utf-16' but when I do an append I get another UTF16 BOM > put into the

[Tutor] Python in a web browser (was Re: finding numbers in range of of numbers)

2008-10-21 Thread Jerry Hill
On Tue, Oct 21, 2008 at 2:26 PM, Richard Lovely <[EMAIL PROTECTED]> wrote: > I don't have internet access, and I've yet to find a public computer > with Python, so I'm unable to test any code I write. I'm going have > to discpline myself not to post to here unless its: a) a problem of my > own, or

Re: [Tutor] Iterate over multiple objects

2008-10-29 Thread Jerry Hill
On Wed, Oct 29, 2008 at 7:30 AM, W W <[EMAIL PROTECTED]> wrote: > I'm trying to compare two strings because I want to find the difference. Albert pointed you to zip so that you can iterate through the two strings in lockstep. You may also want to investigate the python difflib module in the stand

Re: [Tutor] how to read over serial port

2008-11-03 Thread Jerry Hill
On Mon, Nov 3, 2008 at 4:08 PM, shawn bright <[EMAIL PROTECTED]> wrote: > yes, they look like this > �� > > so i used your print repr(chr(ord(i))) and got this Note that that's the same thing as just printing repr(i). > so, what do i do now? > and thanks for the info, by the w

Re: [Tutor] accessing an image with pygame.image.load()

2008-11-03 Thread Jerry Hill
On Mon, Nov 3, 2008 at 7:05 PM, bob gailer <[EMAIL PROTECTED]> wrote: > Christopher Spears wrote: >> self.image = >> pygame.image.load("C:Users\Chris\Documents\python\assignment07\chris_graphics\spaceship.gif") >> > > Since \ is used to "escape" certain characters it is advisable to either use > \\

Re: [Tutor] /not/ instanciating

2008-11-17 Thread Jerry Hill
On Sun, Nov 16, 2008 at 2:57 PM, spir <[EMAIL PROTECTED]> wrote: > * Why, then, is __init__ still executed when the instanciated object is > 'manually' returned? What's the use of that feature? The manual (http://www.python.org/doc/2.5.2/ref/customization.html) says: "If __new__() returns an insta

Re: [Tutor] Deleting recursive folder definition

2009-01-12 Thread Jerry Hill
On Mon, Jan 12, 2009 at 2:07 PM, Alan Gauld wrote: > I've managed to do something incredibly stupid on my XP box. > I've created a folder that is a link to itself - at least I think that's > what has > happened, it was a CASE tool that I was using that actually did the damage. Try exploring the o

Re: [Tutor] How to handle exceptions raised inside a function?

2010-11-30 Thread Jerry Hill
On Tue, Nov 30, 2010 at 3:00 PM, Richard D. Moores wrote: > Both Hlist and Glist must contain only positive numbers, so I really > need to test for this inside each function. But is there a good way to > do this? What should the functions return should a non-positive number > be detected? Is there

Re: [Tutor] floats

2010-12-03 Thread Jerry Hill
On Fri, Dec 3, 2010 at 1:52 PM, Christopher Spears wrote: float_a = 1.16667 > > However, I want to pass the value of float_a to float_b, but I want the float > to be accurate to two decimal points. Use the built-in round() function, like this: >>> a = 1.16667 >>> print a 1.16667 >>> b = ro

Re: [Tutor] Save file in a specific directory

2010-12-07 Thread Jerry Hill
> When I run the script I got the next error: import crawler_shp > Traceback (most recent call last): >   File "", line 1, in >   File "crawler_shp.py", line 105, in >     dbf = Dbf(d,new=False) >   File "C:\Python26\lib\site-packages\dbf.py", line 125, in __init__ >     self.stream = file(f

Re: [Tutor] Importing packages

2011-01-21 Thread Jerry Hill
On Fri, Jan 21, 2011 at 4:10 AM, arun kumar wrote: > Hi, > > I'm trying to program with gdata > (http://code.google.com/p/gdata-python-client/) using python > library.I'm having problem in writing import statements. Have you read the Getting Started document linked from their wiki? Particularly,

Re: [Tutor] The trap of the year

2011-01-25 Thread Jerry Hill
On Tue, Jan 25, 2011 at 3:41 PM, Karim wrote: > I am not really understanding why my init in the class made it refers to > the same list object. > What is the difference with 2nd example directly at the prompt? > See http://effbot.org/zone/default-values.htm -- Jerry __

[Tutor] Homework and the Tutor list

2011-02-02 Thread Jerry Hill
>    I would have to agree with you Ian.  Coming from an art then computer > animation visual effects background, it's not until recently that it became > evident to me that in order to push the potential of this medium, I would > definitely have to learn to code.  I think the stigma of the "homewo

Re: [Tutor] Pygame install help

2011-03-28 Thread Jerry Hill
On Sun, Mar 27, 2011 at 1:31 PM, Chuck wrote: > Does anyone have familiarity with installing pygame? It seems simple and > straight forward enough, then why do I get the following from IDLE? This is > the 3.1 Windows pygame .msi install... You're using pygame (probably pygame 1.9.1) built for pyt

Re: [Tutor] reading very large files

2011-05-17 Thread Jerry Hill
On Tue, May 17, 2011 at 1:20 PM, Vikram K wrote: > I wish to read a large data file (file size is around 1.8 MB) and manipulate > the data in this file. Just reading and writing the first 500 lines of this > file is causing a problem. I wrote: ... > > Traceback (most recent call last): >   File >

Re: [Tutor] lxml.html

2011-06-08 Thread Jerry Hill
On Wed, Jun 8, 2011 at 11:20 AM, nitin chandra wrote: > Hello Every One, > >         doc = lxml.html.parse('/home/dev/wsgi-scripts/index.py').getroot() Is index.py really an XML document? If so, it's named pretty oddly... -- Jerry ___ Tutor maillist

Re: [Tutor] trying to translate and ebcidic file

2011-06-14 Thread Jerry Hill
On Tue, Jun 14, 2011 at 2:40 PM, Prinn, Craig wrote: > I am looking for a way to translate and ebcidic file to ascii. Is there a > pre-existing library for this, or do I need to do this from scratch? If from > scratch and ideas on where to start? If the file is essentially a text file, I would re

Re: [Tutor] which version do i have and how do i change it

2011-08-16 Thread Jerry Hill
On Tue, Aug 16, 2011 at 4:35 PM, Lisi wrote: > lisi@Tux:~$ aptitude why python > i   reportbug Depends python (>= 2.5) > lisi@Tux:~$ Keep in mind that that command only shows you a single dependency chain. Try again with "aptitude -v why python" to see all of the dependencies. On my ubuntu 11.0

Re: [Tutor] String encoding

2011-08-26 Thread Jerry Hill
On Thu, Aug 25, 2011 at 7:07 PM, Prasad, Ramit wrote: > Nice catch! Yeah, I am stuck on the encoding mechanism as well. I know how to > encode/decode...but not what encoding to use. Is there a reference that I can > look up to find what encoding that would correspond to? I know what the > chara

Re: [Tutor] longest common substring

2011-11-11 Thread Jerry Hill
There's nothing wrong with writing your own code to find the longest common substring, but are you aware that python has a module in the standard library that already does this? In the difflib module, the SequenceMatcher class can compare two sequences and extract the longest common sequence of el

Re: [Tutor] Find all strings that....

2011-11-11 Thread Jerry Hill
On Fri, Nov 11, 2011 at 1:21 PM, Francesco Loffredo wrote: > Anyway, taking for granted the rules contained in the edit distance > definition (Thank you, Steven!), I think that finding in a given set S all > words that can be converted into some given "target" with at most N such > operations (be

Re: [Tutor] Cython vs Python-C API

2011-11-14 Thread Jerry Hill
On Mon, Nov 14, 2011 at 3:30 PM, Jaidev Deshpande < deshpande.jai...@gmail.com> wrote: > Hi > > I need to perform cubic spline interpolation over a range of points, and I > have written the code for the same in C and in Python. > > The interpolation is part of a bigger project. I want to front end

Re: [Tutor] In a pickle over pickles….Python 3

2011-11-18 Thread Jerry Hill
On Fri, Nov 18, 2011 at 11:12 AM, Joe Batt wrote: > > pickledfile=open('///Users/joebatt/Desktop/python/pickledpuzzle5.txt','w') > pickle.dump(filecontents,pickledfile) > pickledfile.close() > > A pickle is a binary object, so you'll need to open your picklefile in binary mode: pickledfi

Re: [Tutor] Python Windows Vista Installation Question

2011-12-09 Thread Jerry Hill
On Fri, Dec 9, 2011 at 1:41 PM, Homme, James wrote: > Can Python easily be installed on a Windows Vista computer without needing > administrative rights to that machine? > I thought the standard installer worked for non-admin installs, as long as you select "Just for me" instead of "All users on

Re: [Tutor] Request for guidance about a python syntax

2011-12-19 Thread Jerry Hill
On Mon, Dec 19, 2011 at 10:54 AM, Ganesh Borse wrote: > I could know the use of unpack_from, but I could not understand the "fmt" > part, i.e *"%dH" % nframes * nchannels*. > Can you pls help me know, what is the purpose of two "%" signs in this > statement? > > That's python's string formatting.

Re: [Tutor] Request for guidance about a python syntax

2011-12-19 Thread Jerry Hill
On Mon, Dec 19, 2011 at 12:10 PM, Peter Otten <__pete...@web.de> wrote: > Close, but % and * have the same operator precedence. Therefore the > expression > > "%dH" % nframes * nchannels > > is evaluated as > > (%dH" % nframes) * nchannels > > Thanks Peter, that's exactly correct. Maybe this will

Re: [Tutor] Beginner Exercise: Why Didn't I Break It?

2011-12-20 Thread Jerry Hill
On Tue, Dec 20, 2011 at 12:31 PM, Homme, James wrote: > So far, the data types this little book has talked about are strings and > numbers. ... > return jelly_beans, jars, crates ... > # It returns three things in parentheses, which, I guess is one group of > things. I thought it would complain.

Re: [Tutor] Installing Modules

2012-01-18 Thread Jerry Hill
On Wed, Jan 18, 2012 at 1:07 PM, Downey, Patrick wrote: > I'm currently running Python version 2.7 through IDLE on a Windows machine. > I'm trying to use numpy and scipy. I downloaded both modules from the scipy > website and unzipped the files into: > C:\Python27\Lib\site-packages > That is not

Re: [Tutor] finding a polymer of letters in a string

2012-01-19 Thread Jerry Hill
On Thu, Jan 19, 2012 at 1:44 PM, Hs Hs wrote: > so I do not know what that pattern would be when I read in a string. I do > not know if regex could solve my kind of problem too. > Ignore the python portion of the problem for now. Imagine someone handed you a piece of paper with the letters "AAA

Re: [Tutor] New user Knows nothing about python I Need HELP

2012-01-30 Thread Jerry Hill
On Mon, Jan 30, 2012 at 2:02 PM, William Stewart wrote: > I have no Idea how to start this task I have never used ANY programming > programs before And I dont Know the language either > The online help files from python Did not help a bit Here's a few resources that might get you started. Firs

[Tutor] For/Else loops

2012-02-07 Thread Jerry Hill
On Tue, Feb 7, 2012 at 1:50 PM, Debashish Saha wrote: > for i in range(1, 8): >    print(i) >    if i==3: >        break > else: >    print('The for loop is over') > > >  Output: > 1 > 2 > 3 > > Question:but after breaking the for loop why the else command could not work? Because that's the way a

Re: [Tutor] (no subject)

2012-02-08 Thread Jerry Hill
On Wed, Feb 8, 2012 at 5:21 PM, Joel Goldstick wrote: > The else clause runs if the loop breaks for some reason. So you would > use it only to do some processing if the loop completes completely. > > No. The else clause only runs if the loop does NOT break out early. The else clause only runs i

Re: [Tutor] __name__=='__main__'

2012-02-20 Thread Jerry Hill
On Mon, Feb 20, 2012 at 6:46 PM, Michael Lewis wrote: > I at first put it outside and after all my functions but got the error below That's the right place for it, you just spelled it wrong. > and then put it inside my last function and the program ran. That's not the right place for it. Your

Re: [Tutor] Create a table by writing to a text file.

2012-02-22 Thread Jerry Hill
On Wed, Feb 22, 2012 at 10:24 AM, David Craig wrote: > you had me worried for a minute, but > a = [[]] * 3 > a[0]=[1,2,3] > a > [[1, 2, 3], [], []] > That's not the same thing. In your example you create three copies of the same empty list inside your outer list. You then throw away the first

Re: [Tutor] number of mismatches in a string

2012-03-02 Thread Jerry Hill
On Fri, Mar 2, 2012 at 2:11 PM, Hs Hs wrote: > Hi: > I have the following table and I am interested in calculating mismatch > ratio. I am not completely clear how to do this and any help is deeply > appreciated. > > Length     Matches > 77      24A0T9T36 > 71      25^T9^T37 > 60      25^T9^T26 > 6

Re: [Tutor] creating dict of dict : similar to perl hash of hash

2012-03-06 Thread Jerry Hill
On Tue, Mar 6, 2012 at 6:21 PM, Alan Gauld wrote: > But it doesn't have the same dynamic depth that the Perl version has, you > need to know your maximum depth. The last level will always have the default > set to None. > > You could create a class subclassed from defaultdict that would do it > th

Re: [Tutor] how to build a multiplayer game?

2012-04-11 Thread Jerry Hill
On Wed, Apr 11, 2012 at 9:30 AM, Surya K wrote: > Well, can we make the program so that user enters his IP, DNS addresses > before starting? You could, sure. That's fine for testing purposes, but most people don't know their own IP addresses. Many people don't have a DNS entry for their home PC

Re: [Tutor] need help with a script..

2012-04-11 Thread Jerry Hill
On Wed, Apr 11, 2012 at 9:50 AM, Khalid Al-Ghamdi wrote: > Hi All, > > I'm using python 3.2 on a windows xp. > > I wrote the below script and ran it with the hope of returning a list of > proctors (list_proc), but when it runs it  doesn't call the function > convert_proctors() as intended. On the

Re: [Tutor] is it possible to create and amend classes during run-time?

2012-05-02 Thread Jerry Hill
On Wed, May 2, 2012 at 3:56 PM, Bjorn Madsen wrote: > Hi, > I have been studying http://docs.python.org/tutorial/classes.html for a > while, but still have two questions which I could not answer. Perhaps you > could help? > > Does anyone know if it is possible during run-time to: > a) add attribut

Re: [Tutor] How to exit this loop in the interpreter

2012-05-03 Thread Jerry Hill
On Thu, May 3, 2012 at 9:57 AM, wrote: > Hello all, > > I have encountered the following scenario. > Here is the code - on IDLE on Windows XP. > while True: >     try: >         number = raw_input("enter number - ") >         print number * number >     except ValueError: >         print "in

Re: [Tutor] List Indexing Issue

2012-05-08 Thread Jerry Hill
On Tue, May 8, 2012 at 4:00 PM, Spyros Charonis wrote: > Hello python community, > > I'm having a small issue with list indexing. I am extracting certain > information from a PDB (protein information) file and need certain fields of > the file to be copied into a list. The entries look like this:

Re: [Tutor] pip errors for numpy, scipy matplotlib

2012-05-11 Thread Jerry Hill
On Fri, May 11, 2012 at 2:42 PM, Bjorn Madsen wrote: > Hi, > when attempting to use pip to install numpy, scipy matplotlib I get a mile > of errors. There is simply too much information printed - so it must be a > systematic error (http://paste.ubuntu.com/982180/). What am I missing/doing > wrong?

Re: [Tutor] special attributes naming confusion

2012-06-06 Thread Jerry Hill
On Wed, Jun 6, 2012 at 4:32 PM, Dave wrote: > I'm not sure where this comment belongs, but I want to share my perspective > on the documentation of these special method names. In the following section > there is an inconsistency which could be confusing to someone just learning > Python (e.g., me)

Re: [Tutor] Opening filenames with unicode characters

2012-06-28 Thread Jerry Hill
On Thu, Jun 28, 2012 at 1:55 PM, James Chapman wrote: > Thanks Tim, while this works, I need the name to be stored in a variable as > it's dynamic. > > In other words, how do I rewrite > open(u"blah£.txt") > > to be > filename = "blah£.txt" > open(filename) You have to create a unicode-string, no

Re: [Tutor] Opening filenames with unicode characters

2012-06-28 Thread Jerry Hill
On Thu, Jun 28, 2012 at 2:55 PM, James Chapman wrote: > Why can I not convert my existing byte string into a unicode string? That would work fine. > In the mean time I'll create my original string as unicode and see if that > solves my problem. > fileName = unicode(filename) > > Traceback (

Re: [Tutor] Opening filenames with unicode characters

2012-06-28 Thread Jerry Hill
On Thu, Jun 28, 2012 at 3:48 PM, James Chapman wrote: > Informative thanks Jerry, however I'm not out of the woods yet. > > >> Here's a couple of questions that you'll need to answer 'Yes' to >> before you're going to get this to work reliably: >> >> Are you familiar with the differences between b

  1   2   >