Re: [Tutor] Question regular expressions - the non-greedy pattern

2013-01-21 Thread Lie Ryan
On 22/01/13 10:11, Marcin Mleczko wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello Hugo, hello Walter, first thank you very much for the quick reply. The functions used here i.e. re.match() are taken directly form the example in the mentioned HowTo. I'd rather use re.findall() but I

Re: [Tutor] HELP- Regarding working with python

2013-01-18 Thread Lie Ryan
On 18/01/13 17:11, Gayathri S wrote: hi... I am using principal component analysis for dimensionality reduction in python. am having this following error... >>> import numpy as np >>> import matplotlib.pyplot as plt >>> import mlpy >>> np.random.seed(0) >>> mean,cov,n=[0,0],[[1,1]

Re: [Tutor] Is there space a between "#!" and "/usr/bin/env python" ?

2012-05-01 Thread Lie Ryan
> and is used by the various Unix command shells to specify what program > shall interpret this particular script. To be precise, the shell does not care about the shebang line either, the shebang is interpreted by the program loader in the kernel. The shell simply execve()-ed a script containing

Re: [Tutor] something about sum, integer and delta function

2012-01-16 Thread Lie Ryan
On 01/16/2012 12:57 AM, lina wrote: Hi, are there some modules can be used to do below things like: sum and delta function, and intergeration. Are you trying to graphically render an equation, calculate the results of equation, or algebraically manipulate the equation?

Re: [Tutor] making a custom file parser?

2012-01-07 Thread Lie Ryan
On 01/08/2012 04:53 AM, Alex Hall wrote: Hello all, I have a file with xml-ish code in it, the definitions for units in a real-time strategy game. I say xml-ish because the tags are like xml, but no quotes are used and most tags do not have to end. Also, comments in this file are prefaced by an a

Re: [Tutor] Subclassing Exceptions

2012-01-07 Thread Lie Ryan
On 01/07/2012 03:56 PM, Steven D'Aprano wrote: Chris Fuller wrote: You probably shouldn't inherit from SyntaxError, since it represents syntax errors in the Python code being interpreted or compiled. Any syntax error in your own data structures should be independent of SyntaxError. I'd say a s

Re: [Tutor] Using Python for a client interactive map application

2012-01-06 Thread Lie Ryan
On 01/06/2012 04:16 AM, Alan Gauld wrote: That's a non trivial application. It sounds a lot like Google maps? If by map you meant real world maps, this task becomes pretty much trivial. It is fairly easy to embed Google Map in your own web app, and their API provides a lot for almost anything

Re: [Tutor] python logger

2011-12-28 Thread Lie Ryan
On 12/29/2011 04:13 AM, rail shafigulin wrote: has anyone used python logger before? i'm trying to adapt it for my workplace. right now it is pretty simplistic for me. i'm trying to generate extra output by the LoggerAdapter. however i'm getting errors. specifically i get the following message:

Re: [Tutor] question about pywin32

2011-12-26 Thread Lie Ryan
On 12/27/2011 02:58 AM, Lie Ryan wrote: On 12/27/2011 12:18 AM, daedae11 wrote: Does pywin32 provide a module for AES encryption algorithm ? The description of some module in pywin32 document is so simple that there is not introduction about the function of the function. For example

Re: [Tutor] question about pywin32

2011-12-26 Thread Lie Ryan
On 12/27/2011 12:18 AM, daedae11 wrote: Does pywin32 provide a module for AES encryption algorithm ? The description of some module in pywin32 document is so simple that there is not introduction about the function of the function. For example, "CryptProtectData" function in module win32crypt. --

Re: [Tutor] Wading through traceback output :p:

2011-12-26 Thread Lie Ryan
On 12/26/2011 11:52 PM, Thomas C. Hicks wrote: On Mon, 26 Dec 2011 07:10:45 -0500 Alan Gauld wrote: On 26/12/11 11:42, Thomas C. Hicks wrote: Given it was working before and not now the obvious question is what has changed? It looks like you are on a Linux box so do you have automatic updates

Re: [Tutor] An unknown error in my program

2011-12-25 Thread Lie Ryan
On 12/25/2011 09:46 PM, Joel Goldstick wrote: You can either move the stuff at the top of your program into main, or you could pass the outer new into main as a parameter:main(new): the third alternative is to use the global keyword, e.g. # declare a global named 'new' new = 0 def increm

Re: [Tutor] insert queries into related tables referencing foreign keys using python

2011-12-24 Thread Lie Ryan
On 12/25/2011 01:57 AM, Monte Milanuk wrote: Lie Ryan gmail.com> writes: Be careful that in multithreaded program, each thread should have their own cursors, or otherwise another thread could possibly do another insert before you can query the lastrowid. okay, this touches on someth

Re: [Tutor] A few Python Mysteries [Reset]

2011-12-24 Thread Lie Ryan
On 12/25/2011 06:24 AM, Alan Gauld wrote: On 24/12/11 18:58, Wayne Watson wrote: Yikes. I gave the permissions for .idlerc above. The problem is with recent-files.py. IOError: [Errno 13] Permission denied: 'C:\\Users\\Wayne\\.idlerc\\recent-files.lst' Can you open it in Notepad from the same

Re: [Tutor] A few Python Mysteries [Reset]

2011-12-23 Thread Lie Ryan
On 12/23/2011 03:20 PM, Wayne Watson wrote: Hi, I found it, but not in a place I would expect. It's under my username, Wayne. It is a folder and has three files: breakpoints.lst recent-files.lst ZZrecent-files.lst The last one has the odd ZZ, but is empty. breakpoints.lst is empty too. That c

Re: [Tutor] insert queries into related tables referencing foreign keys using python

2011-12-23 Thread Lie Ryan
On 12/24/2011 11:07 AM, Monte Milanuk wrote: So... most python-sqlite tutorials concentrate on single tables. The few that deal with multiple tables and that mention foreign keys and such seem to demonstrate mainly using hard-coded data instead of parameterized insert queries into tables with au

Re: [Tutor] pygame blinking text

2011-12-12 Thread Lie Ryan
On 12/13/2011 01:01 AM, Cranky Frankie wrote: I tried putting the ty_message block in a WHILE TRUE loop, and that didn't work. Then I tried the same with the games.screen.add(ty_message) line and that didn't work either. I think what might work is if I can find a way to delete the ty_message and

Re: [Tutor] timedelta, difference calculation

2011-12-12 Thread Lie Ryan
On 12/13/2011 06:46 AM, rail shafigulin wrote: i found something interesting during the timedate difference calculation import datetime import time def main(): mydatetime = datetime.datetime.now() time.sleep(1) mydatetime2 = datetime.datetime.now() diff = mydatetime - mydatetime2

Re: [Tutor] how to return an object generated during a python threading code

2011-12-11 Thread Lie Ryan
On 12/11/2011 03:46 AM, Massimo Di Stefano wrote: Hi All, > Trying to read the documentation, i'm looking on how to use " threading.Lock() " and its methods "acquire() and release()" that seems to be the solution to my issue ... but i'm really far to understand how to implement it in my exampl

Re: [Tutor] return, why do I need it?

2011-12-11 Thread Lie Ryan
On 12/12/2011 01:38 AM, Pete O'Connell wrote: Hi I have been writing python code for a while now and I never return anything within any of my functions, I just (eg.) print stuff or make directories or update a log or what have you. When I look at other people's code they are always returning in t

Re: [Tutor] Need Explanation...

2011-12-10 Thread Lie Ryan
On 12/11/2011 04:04 AM, Alan Gauld wrote: On 10/12/11 16:46, Steven D'Aprano wrote: circumstances, regardless of which behaviour was choosen for append, it would catch out some people some time. Probably, although if returning 'self' were the default (which of course only makes sense in a pure

Re: [Tutor] What style do you call Python programming?

2011-12-10 Thread Lie Ryan
On 12/10/2011 03:52 AM, Sarma Tangirala wrote: Well, what I meant was the way you write things like list comprehension. I agree, that comment gave a completely incorrect picture. Sorry about that. list comprehension originated from Haskell, which is a language with a very strong functional pa

Re: [Tutor] print method name

2011-12-08 Thread Lie Ryan
On 12/09/2011 01:49 AM, rail shafigulin wrote: i created a class and in some instances when i use it call some of its methods i need to print a method name. the online search did produce some results but none of them seem to work for me. for example one of them said just to use __name__ or func_n

Re: [Tutor] Prime Factorization Tool

2011-12-04 Thread Lie Ryan
On 12/02/2011 12:15 AM, Robert Sjoblom wrote: So I've recently started poking at the Project Euler site, because I feel that I need to practice writing code. For those of you interested in solving the problems on your own I advice you to not read this, as it will spoil the solution. Problem 3 is

Re: [Tutor] Single line webserver

2011-11-07 Thread Lie Ryan
On 11/08/2011 10:23 AM, Rich Lovely wrote: Hi all, I was part of this list a couple of years ago, and a recent discussion at a python dojo brought to mind something I'd seen then: a one-liner (potentially single statement) webserver. I'm pretty sure it was posted to this list, but I can't fi

Re: [Tutor] Installing the uncertainties module

2011-10-29 Thread Lie Ryan
On 10/30/2011 03:55 PM, Richard D. Moores wrote: On Sat, Oct 29, 2011 at 21:37, Richard D. Moores wrote: On Sat, Oct 29, 2011 at 18:31, Richard D. Moores wrote: The uncertainties module () is now available for 64-bit Python 3.2. I've downloaded un

Re: [Tutor] Installing the uncertainties module

2011-10-29 Thread Lie Ryan
On 10/30/2011 12:31 PM, Richard D. Moores wrote: The uncertainties module () is now available for 64-bit Python 3.2. I've downloaded uncertainties-1.8.tar.gz. I need some utility that will handle both .gz and .tar, I presume. Looking for recommendations. 7zip has always been my multi-format com

Re: [Tutor] Praser

2011-10-23 Thread Lie Ryan
On 10/23/2011 03:09 PM, Henry wrote: Hi Steven, First of all, I want to able to download the data from the web into the database. Here is the part of the link: http://boc.quotepower.com/web/bochk/stocks_mktTransactions.jsp?lang=en&domain=NCBHK&rand=-74344993&lastLevel1Name=nav_stocks&lastStock=

Re: [Tutor] Evaluating program running time?

2011-04-08 Thread Lie Ryan
On 04/09/11 04:29, Cory Teshera-Sterne wrote: > Hi all, > > I have a small(ish) Python program, and I need to be able to log the > running time. This isn't something I've ever really encountered, and > I've been led to believe it can be a little hairy. Are there any > Python-specific approaches to

Re: [Tutor] Python 3.2 Install Not Responding To Python Command!!

2011-04-08 Thread Lie Ryan
On 04/09/11 11:25, Nevins Duret wrote: > Hello Everyone, > > I recently installed python3.2 by building it from source and > noticed that it may have not been > installed 100% correctly. This is probably off topic in python tutor mailing list, better asked on the main mailing list or Ubuntu

Re: [Tutor] Passing a Variable

2011-04-04 Thread Lie Ryan
On 04/04/11 11:55, Ryan Strunk wrote: > Hi list, > > I am in the midst of trying to code a game based entirely on audio cues, and > I've run into a bit of a snag when trying to monitor certain variables. I'll > lay out the framework of what I'm going for in the hope that it makes sense > when writ

Re: [Tutor] sorting based on elements which are nested in a list

2011-04-03 Thread Lie Ryan
On 04/04/11 00:14, ranjan das wrote: > > I have a list which I want to sort based on ('a','b','c') first and then > based on (1,2,3) > > How do i do these using itemgetter() since the list is nested > > A=[('k3', ['b', 3]), ('k2', ['a', 1]), ('k1', ['a', 3]), ('k4', ['c', 2])] > > The solution

Re: [Tutor] 'or' in assignment (not if statement)?

2010-12-11 Thread Lie Ryan
On 12/11/10 04:12, Alan Gauld wrote: > "Steven D'Aprano" wrote >> As an experiment, offer to buy your wife dinner, and ask if she'd >> prefer to go to an Italian or Chinese restaurant. > > :-) > She would either answer "Yes" (she would like to go to one of > them, and if I'm lucky she might give

Re: [Tutor] role playing game - help needed

2010-12-11 Thread Lie Ryan
On 12/07/10 23:37, Robert Sjöblom wrote: > I've been told to use input() if I know that I'll only get integers, > and raw_input() for "everything." That is a bad piece of advice. You should only use input() when you can fully trust whoever doing the input (i.e. you). input() can accept any python

Re: [Tutor] os.listdir for symbolic links?

2010-10-27 Thread Lie Ryan
On 10/28/10 06:57, Sean Carolan wrote: > Is there an easy way to find the target of a symbolic link on a Linux > system with python? I'm looking for something like the output of the > bash command: "ls -l" you're looking for >>> os.path.realpath('/bin/uncompress') '/bin/gunzip'

Re: [Tutor] decorators (the "at" sign)?

2010-10-26 Thread Lie Ryan
On 10/26/10 13:46, Alex Hall wrote: > Hi all, > Now that I am able to run the source code of an open source > application I hope to one day help develop, I am trying to understand > how it works. One thing I keep seeing is an at sign followed by a > word, usually (maybe always) immediately preceedi

Re: [Tutor] What does "TypeError: 'int' object is not iterable" mean?

2010-10-24 Thread Lie Ryan
On 10/23/10 01:19, David Hutto wrote: > If I understand what i just said correctly, it just means it tells the > string what type to convert from when placing it into the final > result. basically, when doing this %-interpolation, python does this: ("NEW LOW: %%.%sf at %%s" % i) % (lowz, time

Re: [Tutor] What's the best way to model an unfair coin?

2010-10-24 Thread Lie Ryan
On 10/25/10 02:46, Jose Amoreira wrote: > On Sunday, October 24, 2010 01:18:52 pm Alan Gauld wrote: > >> In pseudo code: >> >> def coinToss(prob = 0.5): >> rand = random() >> if rand >= prob: return True >> else: return False >> >> print "Heads" if coinToss(6/11) else "Tails" >> > > T

Re: [Tutor] Scripting-Puzzle Pirates

2010-10-24 Thread Lie Ryan
On 10/24/10 15:33, Nathan Finney wrote: > Hey, > > So I got bored of having to do a repeated task on this game, YPP Puzzle > Pirates and I was wondering if it was possible to script it. Even if you can (hint: no, you can't), most games consider writing scripts to do tasks as botting, i.e. cheat

Re: [Tutor] list comprehension, efficiency?

2010-09-27 Thread Lie Ryan
On 09/28/10 13:57, Bill Allen wrote: > I can now see that quite a bit of the code I write dealing with lists > can be done with list > comprehensions. My question is this, is the list comprehension styled > code generally > more efficient at runtime? If so, why? Yes, because the looping in list

Re: [Tutor] super.__init__() arguments

2010-09-27 Thread Lie Ryan
On 09/27/10 09:45, Jojo Mwebaze wrote: > Hey Tutor, > > Seems a small issue but this has been playing for a while now, what am i > doing wrong here? > super() without argument only works for Python 3. In Python 2.x, you have to pass to super your class name and your class instance, i.e.: Class

Re: [Tutor] plotting pixels

2010-09-19 Thread Lie Ryan
On 09/19/10 09:39, ALAN GAULD wrote: >> It appears that the Tk canvas widget does not support simply plotting > a pixel. > > Correct, and I agree it seems odd, but in practice drawing either lines or > ovals of one-pixel do the equivalent job - albeit a little more slowly. More slowly and takes

Re: [Tutor] What are "singletons" good for?

2010-09-18 Thread Lie Ryan
On 09/19/10 02:50, Knacktus wrote: > Hey all, > > the usual explanation for the usage of a Singleton goes like this: > > "Use a singleton if you want to make sure, that only one instance of a > class exists." > > But now I ask myself: Why should I call the constructor of a class more > than once

Re: [Tutor] plotting pixels

2010-09-18 Thread Lie Ryan
> It appears that the Tk canvas widget does not support simply > plotting a pixel. However, I can plot a line only one pixel long. > I wonder why they do not simply provide the pixel plot primitive? I > have seen very many graphics packages that do this and I have always >

Re: [Tutor] "Overloading" methods

2010-09-17 Thread Lie Ryan
On 09/17/10 00:22, Vince Spicer wrote: > > > Well I can't comment on right or wrong I would think creating a simple > class with a __call__ method is a little more pythonic. I think even more pythonic is to use closure: def create_setpattern(type_): def f(self, pattern, parameter):

Re: [Tutor] tree problem

2010-09-12 Thread Lie Ryan
On 09/12/10 21:15, Roelof Wobben wrote: > > > Hello, > > I have this problem. > > Write a program named litter.py that creates an empty file named trash.txt in > each subdirectory of a directory tree given the root of the tree as an > argument (or the current directory as a default). By de

Re: [Tutor] recursive problem

2010-09-11 Thread Lie Ryan
On 09/12/10 03:18, Steven D'Aprano wrote: > Or you could do this: > > if do_this_will_succeed() and do_that_will_succeed() \ > and do_something_else_will_succeed(): > do_this() > do_that() > do_something_else() > else: > do_error() > > But that hasn't done anything to prevent race

Re: [Tutor] recursive problem

2010-09-11 Thread Lie Ryan
On 09/12/10 04:01, Walter Prins wrote: > I guess the question to ask/consider is: How can be establish whether a > particular object supports a particular interface/set of behaviours that > we require? E.g. how do we most pythonically check whether some object > "walks like a list" and "quacks lik

Re: [Tutor] changing list index start

2010-09-11 Thread Lie Ryan
On 09/11/10 23:25, Rance Hall wrote: > On Fri, Sep 10, 2010 at 6:14 PM, Lie Ryan wrote: >> On 09/11/10 07:36, Rance Hall wrote: > > > >> In most cases in Python, you would almost never need to reference the >> list's index directly since python makes it e

Re: [Tutor] changing list index start

2010-09-10 Thread Lie Ryan
On 09/11/10 07:36, Rance Hall wrote: > I'm using the following function style I found on the net to create > menus for a command line python script: > > It works well, but the first item is the list is item 0. This is > normal in most computing situations, but because this index is part of > the

Re: [Tutor] Trouble with sys.path.append

2010-08-08 Thread Lie Ryan
aug dawg gmail.com> writes: > > Earlier today, I tried to add a folder to my PYTHONPATH. When > I tried sys.path.app('location/of/folder'), the command successfully > executed it, but then when I did sys.path to check to see if it was > now in my PYTHONPATH, it was not there. Does anyone know wha

Re: [Tutor] Word to Sound

2010-08-08 Thread Lie Ryan
On Sat, 07 Aug 2010 11:43:25 -0400, Chris King wrote: How do you convert a string into a sound object. Do you mean as in text-to-speech or playing byte string that contain sound data in a certain encoding to the speaker? ___ Tutor maillist -

Re: [Tutor] Idea for a 'Weekly Python Tips' mailing list

2010-08-06 Thread Lie Ryan
On Fri, 6 Aug 2010 17:19:46 +0100, Ian Ozsvald wrote: Recently I've started to follow a couple of email lists that send me regular tip emails, I've found them to be rather nice - an easy to read tip that comes every week that I can digest when I'm ready and I can reference afterwards. In th

Re: [Tutor] "x and y" means "if x is false, then x, else y"??

2010-07-22 Thread Lie Ryan
On 07/05/10 22:23, Adam Bark wrote: > > I should add that this is how something like: > > if x != y: > do_something() > > works, if expects a True or False (this isn't always true but works for > comparison operators expressions such as this). > "if" expects an expression that can be con

Re: [Tutor] (no subject)

2010-06-30 Thread Lie Ryan
On 07/01/10 02:20, Aaron Chambers wrote: > I'm new to Python, and wanted to start messing around with it, but the > computer I'm using is running Windows 7, so is there a version of Python > that's compatible with 7? Yes. ___ Tutor maillist - Tutor@py

Re: [Tutor] OT: need computer advice from wise Tutors

2010-06-29 Thread Lie Ryan
On 06/29/10 19:48, Richard D. Moores wrote: > On Tue, Jun 29, 2010 at 01:06, Alan Gauld wrote: >> "Richard D. Moores" wrote >> You log into Gmail and your browser downloads the Gmail page; >>> >>> Yes, of course. But I'm always logged into Gmail. >> >> But it is still continually downloading

Re: [Tutor] Confirm that Python 2.6 ftplib does not support Unicode file names? Alternatives?

2010-06-24 Thread Lie Ryan
On 06/24/10 02:10, pyt...@bdurham.com wrote: > Can someone confirm that Python 2.6 ftplib does *NOT* support > Unicode file names? Or must Unicode file names be specially > encoded in order to be used with the ftplib module? > I don't know the specifics about ftplib, however I believe in most fil

Re: [Tutor] string encoding

2010-06-18 Thread Lie Ryan
On 06/18/10 14:21, Rick Pasotto wrote: >> Remember, even if your terminal display is restricted to ASCII, you can >> still use Beautiful Soup to parse, process, and write documents in UTF-8 >> and other encodings. You just can't print certain strings with print. > > I can print the string fine. It

Re: [Tutor] string encoding

2010-06-17 Thread Lie Ryan
On 06/18/10 06:41, Rick Pasotto wrote: > I'm using BeautifulSoup to process a webpage. One of the fields has a > unicode character in it. (It's the 'registered trademark' symbol.) When > I try to write this string to another file I get this error: > > UnicodeEncodeError: 'ascii' codec can't encode

Re: [Tutor] Linux webcam libraries?

2010-06-13 Thread Lie Ryan
On 06/13/10 04:22, Wayne Werner wrote: > Hi, > > I want to do something like this: > http://www.kulturblog.com/2007/11/marshie-attacks-halloween-interactive-driveway-activity/ > > I want to be able to grab a webcam image via python. So I'm curious if > anyone has had any experience/luck in this p

Re: [Tutor] Doubts galore.

2010-06-10 Thread Lie Ryan
On 06/11/10 01:14, prasad rao wrote: > Hi > > def cript(doc=None,data =None): >if doc==None and data==None:doc=sys.agv1 >elif doc: > data=open(doc,'r').read() > data_c= binascii.hexlify(data) >else:data_c= binascii.hexlify(data) >if doc: > q=tempfile.Tempor

Re: [Tutor] while loops causing python.exe to crash on windows

2010-06-06 Thread Lie Ryan
On 06/07/10 11:08, Alex Hall wrote: > On 6/6/10, bob gailer wrote: >> On 6/6/2010 8:44 PM, Alex Hall wrote: >>> -- >>> Have a great day, >>> Alex (msg sent from GMail website) >>> mehg...@gmail.com;http://www.facebook.com/mehgcap >>> >>> >> What is your question? >> >> >> -- >> Bob Gailer >> 919-6

Re: [Tutor] backreferences - \0

2010-06-06 Thread Lie Ryan
On 06/06/10 19:36, Payal wrote: > On Sun, Jun 06, 2010 at 06:26:18PM +1000, Steven D'Aprano wrote: >> Two things. Firstly, the Python regex engine numbers backreferences from >> 1, not 0, so you need \1 and not \0. > > Thank for the mail, but i am still not getting it. e.g. > > In first sub I e

Re: [Tutor] OOP clarification needed

2010-06-03 Thread Lie Ryan
On 06/03/10 01:37, Jim Byrnes wrote: > >>> some older procedural languages I always end up becoming confused by >>> the large number of built in methods. >> >> C is one of the simplest procedural languages around >> and yet it comes with a huge library of functions (several >> hundred in some case

Re: [Tutor] class methods as static methods?

2010-05-29 Thread Lie Ryan
On 05/30/10 05:49, Alex Hall wrote: > Hi all, > In Battleship, I have a weapons.py file, currently with just one > missile type (a Harpoon anti-ship missile). This Harpoon class defines > a getImpactCoords method, which returns all coordinates on the map > that it will hit. I would like to not inst

Re: [Tutor] SENTINEL, & more

2010-05-29 Thread Lie Ryan
On 05/29/10 18:29, spir ☣ wrote: > Hello, > > > from the thread: "class methods: using class vars as args?" > > On Sat, 29 May 2010 11:01:10 +1000 Steven D'Aprano > wrote: > >> On Fri, 28 May 2010 07:42:30 am Alex Hall wrote: >>> Thanks for all the explanations, everyone. This does make sense,

Re: [Tutor] Python 2.5.4 - error in rounding

2010-05-23 Thread Lie Ryan
On 05/22/10 22:32, Steven D'Aprano wrote: > On Sat, 22 May 2010 07:16:20 am wesley chun wrote: >> correct, it is a floating point issue regardless of language.. it's >> not just Python. you cannot accurately represent repeating fractions >> with binary digits (bits). more info specific to Python he

Re: [Tutor] Python 2.5.4 - error in rounding

2010-05-21 Thread Lie Ryan
On 05/22/10 01:30, Neven Goršić wrote: > Thanks! > It's pity that Python has such unreliable functions so you never know in > advanced when you will hit new one ... Well, it's not Python but the machine. Floating point number is not Real numbers; there are certain limitations imposed by physical l

Re: [Tutor] Python 2.5.4 - error in rounding

2010-05-21 Thread Lie Ryan
On 05/21/10 20:17, Neven Goršić wrote: > Hi! > > I run into Python error in rounding and not know how to predict when it will > occur in order to prevent wrong result. That's because it's floating point number. > What can I do to assure accurate result? Use decimal module to do precise control

Re: [Tutor] Find Elements in List That Equal A Specific Value

2010-05-12 Thread Lie Ryan
On 05/13/10 03:58, Su Chu wrote: > Hi there, > > I am new to Python. I am attempting to either define a "which" statement or > to find a method that already exists to do this sort of operation. > > My problem is as follows: > I have three lists, one with unique values (list 1), one a sequence of

Re: [Tutor] Unable to run Programs on WINXP using Python3

2010-05-12 Thread Lie Ryan
On 05/12/10 13:31, Sivapathasuntha Aruliah wrote: > Hi > I thank you for your prompt response. I am using WINXP. Possibly programs > written for Python 3 may not work in Python2 as informed by you due to > syntax unmatch. Very unlikely. If python is told to execute a faulty script (or even arb

Re: [Tutor] Question about Python being object oriented

2010-05-08 Thread Lie Ryan
On 05/09/10 02:19, Tino Dai wrote: > Hi Everybody, > > My friend and I were having a disagreement about Python. Has Python > always been an OO language or was it at one point a procedural language like > C? Thanks! AFAIK Python has always been a mixed paradigm language. You can write fully O

Re: [Tutor] Newbie & Unittest ...

2010-05-06 Thread Lie Ryan
On 05/06/10 10:37, Damon Timm wrote: > Hi - am trying to write some unit tests for my little python project - > I had been hard coding them when necessary here or there but I figured > it was time to try and learn how to do it properly. > > This test works, however, it only runs as *one* test (whi

Re: [Tutor] python list, right! but concretely?

2010-05-02 Thread Lie Ryan
On 05/02/10 15:49, spir ☣ wrote: > Hello, > > Is there anywhere some introduction material to the implementation of python > lists > (or to fully dynamic and flexible sequences, in general)? > More precisely, I'd like to know what kind of base data-structure is used > (linked list, dynamic arra

Re: [Tutor] blackjack game

2010-04-29 Thread Lie Ryan
On 04/30/10 06:23, Shurui Liu (Aaron Liu) wrote: > # Blackjack > # From 1 to 7 players compete against a dealer > > > Here is the code of this game. I want to change some part of them. > 1. Since I don't know what part of code is "responsible" for the > number of cards, so I don't know how to ad

Re: [Tutor] Using Regex to produce text

2010-04-28 Thread Lie Ryan
On 04/29/10 01:32, m...@doctors.net.uk wrote: > While some patterns are infinite, other's aren't (e.g. The example I gave). How should the regex engine know about that? > Using a subset of Regex syntax to produce a set of strings has the > advantage of using a well understood and documented for

Re: [Tutor] How can I display my float as a string???

2010-04-27 Thread Lie Ryan
On 04/28/10 12:35, Marco Rompré wrote: > Here is my code, I need to display my float value as a string. > > item.set_prix str(float(prix)) print prix ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.pyt

Re: [Tutor] For loop breaking string methods

2010-04-27 Thread Lie Ryan
On 04/27/10 12:19, Dave Angel wrote: > Note also that if you insert or delete from the list while you're > looping, you can get undefined results. That's one reason it's common > to build a new loop, and just assign it back when done. Example would > be the list comprehension you showed earlier.

Re: [Tutor] Binary search question

2010-04-24 Thread Lie Ryan
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] Binar

Re: [Tutor] the binary math "wall"

2010-04-20 Thread Lie Ryan
On 04/21/10 02:58, Lowell Tackett wrote: > I'm running headlong into the dilemma of binary math representation, with > game-ending consequences, e.g.: > Never use float for representing numbers, use float to represent a "magnitude", do not rely on the exact representation of the number itself.

Re: [Tutor] Loop comparison

2010-04-16 Thread Lie Ryan
On 04/16/10 16:50, 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 > Are you su

Re: [Tutor] Re Problems with creating XML-documents

2010-04-15 Thread Lie Ryan
On 04/15/10 16:03, Karjer Jdfjdf wrote: > When I try to parse the outputfile it creates different errors such as: >* ExpatError: not well-formed (invalid token): That error message is telling you that you're not parsing an XML file, merely an XML-like file. > Basically it ususally has somethi

Re: [Tutor] Menu data from file

2010-04-05 Thread Lie Ryan
On 04/06/10 08:05, Neven Goršić wrote: > OK, I will describe my "case". > > I use menu date stored in list "shape" in file CMFlowData.py in the same > directory as my main program x.py. In the beginning of the program I > have command: > > import CMFlowData > > and everything works fine till I m

Re: [Tutor] Menu data from file

2010-04-05 Thread Lie Ryan
On 04/05/10 17:39, Neven Goršić wrote: > Thank you for mentioning the possible options. > I already use option where I import .py module, > but I run into troubles when making executable with py2exe. Maybe you should elaborate what problems you're experiencing with py2exe? Probably we can solve th

Re: [Tutor] Menu data from file

2010-04-04 Thread Lie Ryan
On 04/05/10 08:54, Alan Gauld wrote: > Thats right you will need to parse the data to convert it into the > format you want. > This is one reason you might find it easier to use XML for storing the data > and use a tool like ElementCTree to parse it. s/ElementCTree/ElementTree/? _

Re: [Tutor] constructor

2010-04-04 Thread Lie Ryan
On 04/05/10 04:11, Shurui Liu (Aaron Liu) wrote: > But the result I got from computer is like this: > A new critter has been born! > A new critter has been born! > > Hi. I'm an instance of class Critter. > > Hi. I'm an instance of class Critter. Because you tell it to do it in that order: cr

Re: [Tutor] simple search and replace...

2010-04-03 Thread Lie Ryan
On 04/01/10 06:51, ALAN GAULD wrote: > But if it's fixed patterns you can either do a replace() > in a loop over your patterns: > > for pat in ['PID','OBR',.] > h7string = h7string.replace('\n'+pat, h7string) > > Or even build a regex that does it all in one. > (But the regex could get co

Re: [Tutor] Simple bank account oriented object

2010-03-30 Thread Lie Ryan
On 03/31/2010 01:26 PM, Marco Rompré wrote: > > Please help me i think im on the right track but i need some guidance in > the dark. lol And what's your question? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: ht

Re: [Tutor] Remote access from Windows PC to a Linux box

2010-03-30 Thread Lie Ryan
On 03/31/2010 03:29 AM, Mike Baker wrote: > Hi, > > I'm trying to connect to a Linux box from my Windows machine and execute > a series of commands - (ls, pwd, cat 'somefile', etc...). I'm using > Putty to do the ssh and have set up with Putty's Pagent agent to allow > me to enter a passphrase

Re: [Tutor] Need some help on "How to Think Like a Computer Scientist: Learning with Python" exercise

2010-03-30 Thread Lie Ryan
On 03/31/2010 04:00 AM, Yahoo Mail wrote: > Hello All, > > I am competely new in Python programming. When i reading Chapter 4 in > "How to Think Like a Computer Scientist: Learning with Python" , > I am stuck in the exercise 4. > > Here is the question: > > Enter the following expressions int

Re: [Tutor] Prime numbers

2010-03-28 Thread Lie Ryan
On 03/28/2010 09:57 PM, yd wrote: > It's not homework i just want to be able to convert my algorithm into > good code, and the only way to do that is by actually writing it. I'm > just writing it to learn how it's done. In most cases, when: 1) the code is effective (i.e. it always gives correct an

Re: [Tutor] Tutorial executable from python script.

2010-03-21 Thread Lie Ryan
On 03/21/2010 08:51 PM, Karim Liateni wrote: > > Hello Lie, > > Thanks for your advices. > > To have correct updates from ITs is really a true pain. The network > is worldwide in our company. I found issues having decent version. > On my local workstation I have Python v1.5, on compute farm LSF

Re: [Tutor] Tutorial executable from python script.

2010-03-21 Thread Lie Ryan
On 03/21/2010 06:00 AM, Karim Liateni wrote: > > Hello Alan, > > In fact, I want to be sure the users can run it on every machine in our > network. > Especially, I want to be able to run it on Solaris 5.8 with python 1.5 > (Unix machine). > I wanted to know if I could make some custom executable

Re: [Tutor] Problems with iterations and breaking loops.

2010-03-17 Thread Lie Ryan
On 03/18/2010 02:02 AM, Karjer Jdfjdf wrote: > I'm having problems with iterations and loops.. So I'm curious about the > best Python-way to do iterations of lists (in if, while etc statements) > and breaking of loops. "Best" is a relative term to the current context of the problem. What is best f

Re: [Tutor] object representation

2010-03-05 Thread Lie Ryan
On 03/05/2010 12:45 PM, Steven D'Aprano wrote: > E.g. a trie needs six pointers just to represent the single > key "python": > > '' -> 'p' -> 'y' -> 't' -> 'h' -> 'o' -> 'n' > > while a hash table uses just one: > > -> 'python' You can argue that had trie beed used as the datatype, there will

Re: [Tutor] Why is the max size so low in this mail list?

2010-03-02 Thread Lie Ryan
On 03/02/2010 04:13 AM, Wayne Watson wrote: > See Subject. 40K here, but other Python lists allow for larger (total) > sizes. I don't know, I've never realized it; that's an indication that the 40K limit is reasonable, at least to me. What did you get for posting >40K mails? Is your mail bounced?

Re: [Tutor] Over-riding radians as default for trig calculations

2010-03-01 Thread Lie Ryan
On 03/01/10 06:39, AG wrote: > After importing the math module and running > > math.cos( x ) > > the result is in radians. > > Is there a way of setting this so that it results in degrees? I don't > want to over-ride this permanently for my Python settings, so am happy > to specifically do it p

Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-02-28 Thread Lie Ryan
On 03/01/10 02:49, Karim Liateni wrote: > Lie Ryan wrote: >> On 03/01/10 01:12, Alan Gauld wrote: >> >>>> def getLines(file): >>>> """Get the content of a file in a lines list form.""" >>>> f =

Re: [Tutor] Any Tutor there ? Removing redundant parameters in a models file having include files.

2010-02-28 Thread Lie Ryan
On 03/01/10 01:12, Alan Gauld wrote: > >> def getLines(file): >> """Get the content of a file in a lines list form.""" >> f = open(file, 'r') >> lines = f.readlines() >> f.close() >> return lines > > I'm not sure these functions add enough value to ghave them. I';d > probably just use >

Re: [Tutor] How to use pydoc

2010-02-27 Thread Lie Ryan
On 02/27/10 00:31, Ricardo Aráoz wrote: > Checked the manuals on pydoc and wanted to try it. Must certainly be > doing something wrong but I can't figure what. Here's my session : The pydoc command works from your system shell (e.g. bash), not python shell; if you want to get help inside python's

  1   2   3   4   >