Re: XML Parsing

2009-02-24 Thread Lie Ryan
On Tue, 24 Feb 2009 20:50:20 -0800, Girish wrote: Hello, I have a xml file which is as follows: pids Parameter_Class Parameter Id=pid_031605_093137_283 Identifier$/Identifier TypePID/Type

Re: XML Parsing

2009-02-24 Thread Lie Ryan
On Wed, 2009-02-25 at 06:09 +, hrishy wrote: Hi I am just a python enthusiast and not a python user but was just wundering why didnt the list members come up with or recommen XPATH based solution which i think is very elegant for this type of a problem isnt it ? Did you mean XQuery?

Re: XML Parsing

2009-02-24 Thread Lie Ryan
Are you searching for answer or searching for another people that have the same answer as you? :) Many roads lead to Rome is a very famous quotation... -- http://mail.python.org/mailman/listinfo/python-list

Re: How best to test functions which use date.today

2009-02-28 Thread Lie Ryan
Yuan HOng wrote: HI, In my project I have several date related methods which I want tested for correctness. The functions use date.today() in several places. Since this could change every time I run the test, I hope to find someway to fake a date.today. For illustration lets say I have a

Re: Creating Zip file like java jar file

2009-02-28 Thread Lie Ryan
zaheer.ag...@gmail.com wrote: On Feb 28, 11:15 pm, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Sat, 28 Feb 2009 14:34:15 -0200, zaheer.ag...@gmail.com escribió: I want to create zip file equivalent to java jar file,I created a zip file of my sources and added some __main__.py it says

Re: Bug report: ClientForm

2009-02-28 Thread Lie Ryan
MRAB wrote: Muddy Coder wrote: Hi Folks, When it parses a form, if the VALUE of a field has not space, it works very well. For example, if a dropdown list, there many options, such as: option value=foo the value foo will be picked up for sure. But, if there is a space: option

Re: OTish: convince the team to drop VBScript

2009-02-28 Thread Lie Ryan
Christian R. wrote: The company does use Python on rare occasions. It all comes down to the prejudices and habits of one of the programmers. His only argument I can't counter -because I don't see the problem- is that Python modules cause problems for updates to customer's installations. Next

Re: Email Program

2009-02-28 Thread Lie Ryan
J wrote: Is it possible to make a GUI email program in Python that stores emails, composes, ect? Also, could I create my own programming language in Python? What are Pythons limits, or is this just a waste of my time to learn it. -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterator class to allow self-restarting generator expressions?

2009-03-02 Thread Lie Ryan
Gabriel Genellina wrote: En Sun, 01 Mar 2009 15:51:07 -0200, Chris Rebert c...@rebertia.com escribió: On Sun, Mar 1, 2009 at 8:54 AM, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Sun, 01 Mar 2009 13:20:28 -0200, John O'Hagan resea...@johnohagan.com escribió: Inspired by some recent

Re: Python parser

2009-03-02 Thread Lie Ryan
Clarendon wrote: Can somebody recommend a good parser that can be used in Python programs? Do you want parser that can parse python source code or parser that works in python? If the latter, pyparsing is a popular choice. Ply is another. There are many choice:

Re: Inverse of dict(zip(x,y))

2009-03-04 Thread Lie Ryan
Andre Engels wrote: y = d.values() might also work, but I am not sure whether d.keys() and d.values() are guaranteed to use the same order. If they were called immediately after each other I think they should, but better not rely on it. -- http://mail.python.org/mailman/listinfo/python-list

Re: Inverse of dict(zip(x,y))

2009-03-04 Thread Lie Ryan
Lorenzo wrote: zip() in conjunction with the * operator can be used to unzip a list: That's because zip is the inverse operation of zip. I remember someone saying that zip's typical name is transpose (like in matrix transpose). a == zip(*zip(*a)) nitpick * in argument unpacking is not

Re: Pickle Problem

2009-03-04 Thread Lie Ryan
Fab86 wrote: Is there another way rather than closing the file? Is it possible to delete all within the file? Thanks Delete the old file then opening (and creating) it again is the easiest way? If you need the data from the old file, you can rename the old file and reopen (and create) a

Re: Peculiar swap behavior

2009-03-04 Thread Lie Ryan
andrew cooke wrote: Delaney, Timothy (Tim) wrote: Tim Chase wrote: # swap list contents...not so much... m,n = [1,2,3],[4,5,6] m[:],n[:] = n,m m,n ([4, 5, 6], [4, 5, 6]) [...] For these types of things, it's best to expand the code out. The appropriate expansion of: m,n =

Re: Can't override class |__new__

2009-03-05 Thread Lie Ryan
jelle feringa wrote: Hi, I'm working with a C++ module ( CGAL, comp.geom. with exact arithmic ) and am having troubles finding a way to override how the modules returns objects. What I'm trying to do is to extend the Facet class, but when I try to use my version of the class, the parent class

Re: Can't override class |__new__

2009-03-05 Thread Lie Ryan
jelle feringa wrote: CGAL.Facet = OtherFacet CGAL.Polyhedron.Facet = OtherFacet p = CGAL.Polyhedron_3() You're not creating Facet object here, not even Polyhedron.Facet. Right, which is not the point; I'm trying to override the Facet, a topological entity of which a Polyhedron is composed

Re: Can Python do shopping cart?

2009-03-06 Thread Lie Ryan
Muddy Coder wrote: Hi Folks, I know PHP can do shopping cart, such as Zen Cart. I wonder can Python do such a thing? Thanks! Muddy Coder Python is Turing Complete -- http://mail.python.org/mailman/listinfo/python-list

Re: Should I use stackless python or threads?

2009-03-06 Thread Lie Ryan
Minesh Patel wrote: On Fri, Mar 6, 2009 at 3:16 PM, Jean-Paul Calderone exar...@divmod.com wrote: On Fri, 6 Mar 2009 14:50:51 -0800, Minesh Patel min...@gmail.com wrote: I am trying to figure out the best approach to solve this problem: I want to poll various directories(can be run in the

Re: python image - ignore values in resize

2009-03-06 Thread Lie Ryan
Travis Kirstine wrote: I have be attempting to resize (downsample) a RGB image using the python image library resize function. Everything works fine but I would like to exclude black values 0,0,0 from the calculations. I have tried creating a alpha mask based on black values then performing

Re: wxPython fast and slow

2009-03-06 Thread Lie Ryan
iu2 wrote: Do you have any idea of what is going wrong? I think this might be related to the OS's process prioritization, focused Windows would get more priority than background window. -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing/Crawler Questions - solution

2009-03-07 Thread Lie Ryan
bruce wrote: john... again the problem i'm facing really has nothing to do with a specific url... the app i have for the usc site works... but for any number of reasons... you might get different results when running the app.. -the server could be screwed up.. -data might be cached -data

Re: create boolean

2009-03-07 Thread Lie Ryan
Fencer wrote: Hi, I need a boolean b to be true if the variable n is not None and not an empty list, otherwise b should be false. I ended up with: b = n is not None and not not n which seems to work but is that normally how you would do it? It can be assumed that n is always None or a list that

Re: /a is not /a ?

2009-03-07 Thread Lie Ryan
Steven D'Aprano wrote: Albert Hopkins wrote: I would think (not having looked) that the implementation of == would first check for identity (for performance reasons)... For some types, it may. I believe that string equality testing first tests whether the two strings are the same string,

Re: Is there a better way of doing this?

2009-03-07 Thread Lie Ryan
mattia wrote: Il Sat, 07 Mar 2009 00:05:53 -0200, Gabriel Genellina ha scritto: En Fri, 06 Mar 2009 21:31:01 -0200, mattia ger...@gmail.com escribió: Thanks, I've found another solution here: http://www.obitko.com/tutorials/ genetic-algorithms/selection.php so here is my implementation:

Re: /a is not /a ?

2009-03-08 Thread Lie Ryan
Mel wrote: wrote: Steven D'Aprano st...@pearwood.info writes: It is never correct to avoid using is when you need to compare for identity. When is it ever necessary to compare for identity? Ho-hum. MUDD game. def broadcast (sender, message): for p in all_players: if p is not

Re: /a is not /a ?

2009-03-08 Thread Lie Ryan
Robert Kern wrote: On 2009-03-07 08:14, Christian Heimes wrote: Steven D'Aprano wrote: Yes. Floating point NANs are required to compare unequal to all floats, including themselves. It's part of the IEEE standard. As far as I remember that's not correct. It's just the way C has interpreted

Re: help with printing to stdout...

2009-03-08 Thread Lie Ryan
Chris Rebert wrote: On Sun, Mar 8, 2009 at 1:37 AM, Daniel Dalton d.dal...@iinet.net.au wrote: Hi, I've got a program here that prints out a percentage of it's completion. Currently with my implimentation it prints like this: 0% 1% 2% 3% 4% etc taking up lots and lots of lines of output...

Re: 2.6.1 - simple division

2009-03-08 Thread Lie Ryan
farsi...@gmail.com wrote: On Mar 8, 2:16 pm, farsi...@gmail.com wrote: 4 / 5.0 0.84 This one is a common FAQ. Basically floating point is never to be trusted. This issue is quite language agnostic, however some language decided to hide the issue, python does not. For more

Re: Callback from c thread with ctypes

2009-03-08 Thread Lie Ryan
Victor Lin wrote: On 3月8日, 下午9時56分, Diez B. Roggisch de...@nospam.web.de wrote: Victor Lin schrieb: Hi, I am going to develop a c library binding with ctypes. That c library will call callback from worker threads it created. Here comes the problem : Will the GIL be acquired before it goes

Re: create boolean

2009-03-08 Thread Lie Ryan
Scott David Daniels wrote: Lie Ryan wrote: Fencer wrote: The literal translation of that would be: if n is not None and n != []: b = True else: b = False it is a bit verbose, so one might want to find something shorter b = True if n is not None and n != [] else False I always feel

Re: 2.6.1 - simple division

2009-03-09 Thread Lie Ryan
Duncan Booth wrote: farsi...@gmail.com wrote: Thanks all, that's very helpful, sorry to waste your time with a common question. I have tried the decimal module and will definitely keep using it if I need to do this kind of calculation again. Try to remember though that the decimal module

Re: a potential pep to extend the syntax of for loops

2009-03-09 Thread Lie Ryan
Hello, This is an idea about something I'd like to see implemented in python. I understand that's the purpose of PEPs, so I'll write it as a PEP, but send it here to receive your valuable feedback. Abstract This is a proposal to increase the richness of for loops, only to the extent that it

Re: Is python worth learning as a second language?

2009-03-09 Thread Lie Ryan
ZikO wrote: Hi I hope I won't sound trivial with asking my question. I am a C++ programmer and I am thinking of learning something else because I know second language might be very helpful somehow. I have heard a few positive things about Python but I have never writen any single line in

Re: Is python worth learning as a second language?

2009-03-09 Thread Lie Ryan
Michele Simionato wrote: On Mar 9, 12:47 pm, Tim Wintle tim.win...@teamrubber.com wrote: My slight issue with this list that I think things are in too many places. Yeah, that issue did pass through my head when I posted it, but I was too lazy to do proper listing of various language from

Re: Set Frozenset?

2009-03-10 Thread Lie Ryan
Matt Nordhoff wrote: Alan G Isaac wrote: Hans Larsen schrieb: How could I take an elemment from a set or a frozenset On 3/8/2009 2:06 PM Diez B. Roggisch apparently wrote: You iterate over them. If you only want one value, use iter(the_set).next() I recall a claim that

Re: Set Frozenset?

2009-03-11 Thread Lie Ryan
R. David Murray wrote: Lie Ryan lie.1...@gmail.com wrote: Matt Nordhoff wrote: Alan G Isaac wrote: Hans Larsen schrieb: How could I take an elemment from a set or a frozenset On 3/8/2009 2:06 PM Diez B. Roggisch apparently wrote: You iterate over them. If you only want one

Re: functions - where to store them

2009-03-11 Thread Lie Ryan
plsulliv...@gmail.com wrote: I have several functions which I would like to store in a different directory so several programs can use them. I can't seem to find much information about how to call a function if the function code is not actually in the script itself. The problem: do I have to cut

Re: UnicodeEncode Error ?

2009-03-11 Thread Lie Ryan
Rama Vadakattu wrote: While doing the below 1) fetch html page 2) extract title using BeatifulSoup 3) Save into the database. iam getting the below error (at the bottom). Few observations which i had: 1) type of variable which holds this title is class 'BeautifulSoup.NavigableString'

Re: Why is lambda allowed as a key in a dict?

2009-03-12 Thread Lie Ryan
Terry Reedy wrote: r wrote: On Mar 11, 3:40 pm, Craig Allen callen...@gmail.com wrote: On Mar 10, 1:39 pm, Paul Rubin http://phr...@nospam.invalid wrote: Identical strings don't necessarily have the same id: A more verbose way to put this is Requesting a string with a value that is the

Re: unbiased benchmark

2009-03-12 Thread Lie Ryan
Martin P. Hellwig wrote: Philip Semanchuk wrote: On Mar 12, 2009, at 4:20 PM, Daniel Fetchinson wrote: Even more amazingly, it takes approximately 30% less time to say 'ruby' than to say 'python'!!! But python scores 55% more points than ruby in Scrabble, so that's understandable. It

Re: loop performance in global namespace (python-2.6.1)

2009-03-12 Thread Lie Ryan
John Machin wrote: On Mar 13, 2:41 am, spir denis.s...@free.fr wrote: Le Thu, 12 Mar 2009 11:13:33 -0400, Kent Johnson ken...@tds.net s'exprima ainsi: Because local name lookup is faster than global name lookup. Local variables are stored in an array in the stack frame and accessed by index.

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Lie Ryan
Hendrik van Rooyen wrote: Ulrich Eckhardt eck...aser.com wrote: IOW, why not explicitly say what you want using keyword arguments with defaults instead of inventing an IMHO cryptic, read-only mini-language? Seriously, the problem I see with this proposal is that its aim to be as short as

Re: import not working?

2009-03-13 Thread Lie Ryan
Scott David Daniels wrote: Aahz wrote: In article mailman.605.1235434737.11746.python-l...@python.org, Rhodri James rho...@wildebst.demon.co.uk wrote: ... sys.path.append(C:\\DataFileTypes) My preference: sys.path.append(rC:\DataFileTypes) This doesn't work if you need to add a trailing

Re: __import__ with dict values

2009-03-13 Thread Lie Ryan
Gabriel Genellina wrote: En Thu, 12 Mar 2009 09:27:35 -0200, alex goretoy aleksandr.gore...@gmail.com escribió: note i would still like to be able to do __import__(sys).path p = __import__(sys).path That's a convoluted way of doing: import sys p = sys.path (except that the latter one

Re: Raw String Question

2009-03-13 Thread Lie Ryan
MRAB wrote: In Python 3.x a backslash doesn't have a special meaning in a raw string, except that it can prevent a following quote from ending the string, but the backslash is still included. Why? How useful is that? I think it would've been simpler if a backslash had _no_ special effect, not

Re: import not working?

2009-03-13 Thread Lie Ryan
Steve Holden wrote: Lie Ryan wrote: Scott David Daniels wrote: Aahz wrote: In article mailman.605.1235434737.11746.python-l...@python.org, Rhodri James rho...@wildebst.demon.co.uk wrote: ... sys.path.append(C:\\DataFileTypes) My preference: sys.path.append(rC:\DataFileTypes) This doesn't

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Lie Ryan
Raymond Hettinger wrote: [andrew cooke] would it break anything to also allow format(1234567, 'd') # what we have now '1234567' format(1234567, '.d') # proposed new option '1.234.567' format(1234.5, ',2f') # proposed new option '1234,50' format(1234.5, '.,2f') #

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Lie Ryan
Raymond Hettinger wrote: Motivation: Provide a simple, non-locale aware way to format a number with a thousands separator. Adding thousands separators is one of the simplest ways to improve the professional appearance and readability of output exposed to end users.

Re: __import__ with dict values

2009-03-13 Thread Lie Ryan
Gabriel Genellina wrote: En Fri, 13 Mar 2009 17:12:49 -0200, alex goretoy aleksandr.gore...@gmail.com escribió: wow, ok, thank you Gabriel, I wasn't aware of x,'y',z This is what I decided to go with for now in one of my classes, but another class will need a modified version of this, as

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Lie Ryan
Raymond Hettinger wrote: If anyone here is interested, here is a proposal I posted on the python-ideas list. The idea is to make numbering formatting a little easier with the new format() builtin in Py2.6 and Py3.0: http://docs.python.org/library/string.html#formatspec

Re: Rough draft: Proposed format specifier for a thousands separator

2009-03-13 Thread Lie Ryan
Raymond Hettinger wrote: [Lie Ryan] In the finance world, output with commas is the norm. I can't cite any source, but I am skeptical with that. No doubt that you're skeptical of anything you didn't already know ;-) I'm a CPA, was a 15 year division controller for a Fortune 500

Re: String to sequence

2009-03-14 Thread Lie Ryan
mattia wrote: Il Sat, 14 Mar 2009 10:30:43 +0100, Vlastimil Brom ha scritto: 2009/3/14 mattia ger...@gmail.com: How can I convert the following string: 'AAR','ABZ','AGA','AHO','ALC','LEI','AOC', EGC','SXF','BZR','BIQ','BLL','BHX','BLQ' into this sequence:

Re: List the moduels of a package

2009-03-15 Thread Lie Ryan
mattia wrote: Hi all, how can I list the modules provided by a package? import package help(package) -- http://mail.python.org/mailman/listinfo/python-list

Re: What is not objects in Python?

2008-09-30 Thread Lie Ryan
On Mon, 2008-09-29 at 21:03 -0700, namekuseijin wrote: On 28 set, 15:29, process [EMAIL PROTECTED] wrote: I have heard some criticism about Python, that it is not fully object- oriented. So what? Why isn't len implemented as a str.len and list.len method instead of a len(list)

Re: rpath

2008-09-30 Thread Lie Ryan
On Tue, 30 Sep 2008 10:50:01 -0700, Kyle Hayes wrote: Please describe the actual problem you're trying to solve. In what way do slashes need to be fixed, and why? Well, I have decided to build a tool to help us sync files in UNC paths. I am just building the modules and classes right now so

Re: [Tutor] Replacing cmd.exe with custom .py application

2008-09-30 Thread Lie Ryan
On Tue, 30 Sep 2008 15:09:06 -0400, Ezra Taylor wrote: Is there something similar to /dev/null on Windows? I think it's called nul REM This is a batch file (.bat) echo This won't show NUL I'm not sure how to use it in python though. -- http://mail.python.org/mailman/listinfo/python-list

Re: Output of pexpect

2008-10-01 Thread Lie Ryan
On Tue, 30 Sep 2008 20:48:12 -0700, Anh Khuong wrote: I am using pexpect and I want to send output of pexpet to both stdout and log file concurrently. Anybody know a solution for it please let me know. One way is to create a file-like object that forked the output to stdout and the logfile.

Re: ssh keepalive

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 00:30:59 -0700, loial wrote: I have a problem with a ssh connection in python I get the error 'NoneType' object has no attribute 'exec_command' I am thinking that maybe the ssh connection is timeing out. Since I have no control over the configuration of the ssh

Re: Event-driven framework (other than Twisted)?

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 01:01:41 -0700, Phillip B Oldham wrote: Are there any python event driven frameworks other than twisted? Most GUI package use event-driven model (e.g. Tkinter). -- http://mail.python.org/mailman/listinfo/python-list

Re: Tix: Windows XP: Problem - how to stop root window from popping up with Tix

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 11:33:59 +0100, dudeja.rajat wrote: Hi, Im using Tix on widows XP and I've tried many ways to suppress the root window. But so far I'm unable to do it. Please suggest how can I suppress the root window. My code is as follows: import Tix myRoot = Tix.Tk()

Re: ssh keepalive

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 10:47:28 +, Marc 'BlackJack' Rintsch wrote: On Wed, 01 Oct 2008 08:07:43 +, Lie Ryan wrote: a = [1, 3, 4, 2] a = a.sort() print a [None, None, None, None] *That* would be really odd. The last line should be just a singel `None` and not a list. :-) Ciao

Re: indirectly addressing vars in Python

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 10:53:08 -0400, Ross wrote: Forgive my newbieness - I want to refer to some variables and indirectly alter them. Not sure if this is as easy in Python as it is in C. Say I have three vars: oats, corn, barley I add them to a list: myList[{oats}, {peas}, {barley}]

Re: text file

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 07:19:44 -0700, yqyq22 wrote: My problem is how to translate this vbs in python: Dim fso Dim strComputer Set fso = CreateObject(Scripting.FileSystemObject) Set ElencoPC = fso.OpenTextFile(elencoPC.txt , 1, False) Do Until ElencoPC.AtEndOfStream strComputer =

Re: Peek inside iterator (is there a PEP about this?)

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 10:46:33 -0400, Luis Zarrabeitia wrote: Hi there. For most use cases I think about, the iterator protocol is more than enough. However, on a few cases, I've needed some ugly hacks. Ex 1: a = iter([1,2,3,4,5]) # assume you got the iterator from a function and b =

Re: Isolated environment for execfile

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 11:11:29 +, Igor Kaplan wrote: Hello python gurus. I got quite unusual problem and all my searches to find the answer on my own were not successful. Here is the scenario: I have the python program, let's call it script1.py, this program needs to execute

Re: parse a normal textfile

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 14:09:09 +0200, Tino Wildenhain wrote: devi thapa wrote: hi all I have one normal text file. I need to parse the file, that too in an associative way . suppose that below is the normal textfile name='adf' id =1 value=344 there are many approaches

Re: Event-driven framework (other than Twisted)?

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 18:09:20 +0200, Bruno Desthuilliers wrote: Phillip B Oldham a écrit : On Oct 1, 4:12 pm, Thomas Guettler [EMAIL PROTECTED] wrote: Please explain what you want to do. I'm primarily looking for alternatives to MVC frameworks for web development, particularly SAAS. I've

Re: How to emit UTF-8 from console mode?

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 08:17:15 -0700, Siegfried Heintze wrote: (snip) The code was a little confusing because those two apostrophes look like a double quote! Tips: use mono-spaced font. There is no ambiguity. (snip) I think part of the problem is that Lucida Console is not as capable as

Re: string concatenate

2008-10-01 Thread Lie Ryan
On Wed, 01 Oct 2008 09:41:57 -0700, sandric ionut wrote: Hi: I have the following situation:     nameAll = [] Here you defined nameAll as a list     for i in range(1,10,1): That range is superfluous, you could write this instead[1]: for i in range(10):     n = name + str([i]) in

Re: code critique requested - just 60 lines

2008-10-02 Thread Lie Ryan
On Thu, 02 Oct 2008 07:51:30 -0700, Terrence Brannon wrote: Hi, I would like some feedback on how you would improve the following program: http://www.bitbucket.org/metaperl/ptc_math/src/21979c65074f/payout.py Basically, using non-strict dictionary keys can lead to bugs, so that worried me.

Re: windows help files ?

2008-10-02 Thread Lie Ryan
On Thu, 02 Oct 2008 17:13:50 +0200, Stef Mientki wrote: Hello, I've 2 questions about python help files: Python help files or your program's help files? 1. how can I launch the windows help file (CHM), from python with a keyword as argument ? I'm not really sure, but isn't CHM obsoleted

Re: why? __builtins__ key added from eval

2008-10-02 Thread Lie Ryan
On Tue, 30 Sep 2008 16:04:34 -0500, William Purcell wrote: I want to use eval to evaluate wx.TextCtrl inputs. How can I keep python from adding the __builtins__ key to mydict when I use it with eval? Other wise I have to __delitem__('__builtins__') everytime I use eval? mydict =

Re: Efficient Bit addressing in Python.

2008-10-09 Thread Lie Ryan
On Fri, 10 Oct 2008 00:30:18 +0200, Hendrik van Rooyen wrote: Is there a canonical way to address the bits in a structure like an array or string or struct? Or alternatively, is there a good way to combine eight ints that represent bits into one of the bytes in some array or string or

Re: Safe eval of insecure strings containing Python data structures?

2008-10-09 Thread Lie Ryan
On Thu, 09 Oct 2008 13:26:17 +0100, Orestis Markou wrote: The ast module in 2.6 has something... in python 2.6, ast.literal_eval may be used to replace eval() for literals. It does not accepts statements and function calls, i.e.: a = set([1, 2, 3]) repr(a) set([1, 2, 3])

Re: Pr. Euler 18, recursion problem

2008-10-09 Thread Lie Ryan
On Mon, 06 Oct 2008 00:14:37 -0700, process wrote: On Oct 6, 8:13 am, Aidan [EMAIL PROTECTED] wrote: process wrote: I am trying to solve project euler problem 18 with brute force(I will move on to a better solution after I have done that for problem 67).

Re: Overloading operators

2008-10-16 Thread Lie Ryan
On Wed, 15 Oct 2008 14:34:14 +0200, Mr.SpOOn wrote: Hi, in a project I'm overloading a lot of comparison and arithmetic operators to make them working with more complex classes that I defined. What is the best way to do this? Shall I use a lot of if...elif statements inside the overloaded

Re: indentation

2008-10-20 Thread Lie Ryan
On Sun, 19 Oct 2008 07:16:44 -0700, Gandalf wrote: every time I switch editor all the script indentation get mixed up, and python start giving me indentation weird errors. indentation also hard to follow because it invisible unlike brackets { } is there any solution to this problems?

Re: Idenfity numbers in variables

2008-10-20 Thread Lie Ryan
On Mon, 20 Oct 2008 13:16:48 +0200, Alfons Nonell-Canals wrote: Hello, I have a trouble and I don't know how to solve it. I am working with molecules and each molecule has a number of atoms. I obtain each atom spliting the molecule. Ok. It is fine and I have no problem with it. The

Re: a question about Chinese characters in a Python Program

2008-10-20 Thread Lie Ryan
On Sun, 19 Oct 2008 22:32:20 -0700, est wrote: On Oct 20, 10:48 am, Liang Chen [EMAIL PROTECTED] wrote: Hope you all had a nice weekend. I have a question that I hope someone can help me out. I want to run a Python program that uses Tkinter for the user interface (GUI). The program allows

Re: what's the python for this C statement?

2008-10-20 Thread Lie Ryan
On Mon, 20 Oct 2008 12:34:11 +0200, Hrvoje Niksic wrote: Michele [EMAIL PROTECTED] writes: Hi there, I'm relative new to Python and I discovered that there's one single way to cycle over an integer variable with for: for i in range(0,10,1) Please use xrange for this purpose, especially

Re: IRC

2008-10-22 Thread Lie Ryan
On Tue, 21 Oct 2008 05:59:43 -0700, Amie wrote: HI All, Please can you perhaps provide me with links or good places where I can learn what IRC is, how to work with it and how to write to a large log file at the same time as letting the IRC spy read and write to the server. Thank You

Re: PIL: Getting a two color difference between images

2008-10-25 Thread Lie Ryan
On Fri, 24 Oct 2008 14:51:07 -0500, Kevin D. Smith wrote: I'm trying to get the difference of two images using PIL. The ImageChops.difference function does almost what I want, but it takes the absolute value of the pixel difference. What I want is a two color output image: black where the

Re: Urllib vs. FireFox

2008-10-25 Thread Lie Ryan
On Fri, 24 Oct 2008 20:38:37 +0200, Gilles Ganault wrote: Hello After scratching my head as to why I failed finding data from a web using the re module, I discovered that a web page as downloaded by urllib doesn't match what is displayed when viewing the source page in FireFox. Cookies?

Re: from package import * without overwriting similarly named functions?

2008-10-25 Thread Lie Ryan
On Fri, 24 Oct 2008 11:06:54 -0700, Reckoner wrote: I have multiple packages that have many of the same function names. Is it possible to do from package1 import * from package2 import * without overwriting similarly named objects from package1 with material in package2? How about a way

Re: How can I handle the char immediately after its input, without waiting an endline?

2008-10-25 Thread Lie Ryan
I want to write something that handle every char immediately after its input. Then tehe user don't need to type [RETURN] each time. How can I do this? Thanks in advance. Don't you think that getting a one-character from console is something that many people do very often? Do you think that

Re: Ordering python sets

2008-10-25 Thread Lie Ryan
On Wed, 22 Oct 2008 10:43:35 -0700, bearophileHUGS wrote: Mr.SpOOn: Is there another convenient structure or shall I use lists and define the operations I need? musings As Python becomes accepted for more and more serious projects some more data structures can eventually be added to the

Re: set/dict comp in Py2.6

2008-10-25 Thread Lie Ryan
On Sat, 25 Oct 2008 09:07:35 +, Steven D'Aprano wrote: On Sat, 25 Oct 2008 01:13:08 -0700, bearophileHUGS wrote: I'd like to know why Python 2.6 doesn't have the syntax to create sets/ dicts of Python 3.0, like: {x*x for x in xrange(10)} {x:x*x for x in xrange(10)} Maybe nobody

Re: How can I handle the char immediately after its input, without waiting an endline?

2008-10-25 Thread Lie Ryan
On Sat, 25 Oct 2008 09:04:01 +, Steven D'Aprano wrote: On Sat, 25 Oct 2008 08:36:32 +, Lie Ryan wrote: I want to write something that handle every char immediately after its input. Then tehe user don't need to type [RETURN] each time. How can I do this? Thanks in advance. Don't

Re: Improving interpreter startup speed

2008-10-25 Thread Lie Ryan
On Sat, 25 Oct 2008 12:32:07 -0700, Pedro Borges wrote: Hi guys, Is there a way to improve the interpreter startup speed? In my machine (cold startup) python takes 0.330 ms and ruby takes 0.047 ms, after cold boot python takes 0.019 ms and ruby 0.005 ms to start. TIA um... does

Re: Ordering python sets

2008-10-25 Thread Lie Ryan
On Sat, 25 Oct 2008 09:21:05 +, Steven D'Aprano wrote: On Sat, 25 Oct 2008 08:58:18 +, Lie Ryan wrote: anotherrandommusing Since python is dynamic language, I think it should be possible to do something like this: a = list([1, 2, 3, 4, 5], implementation = 'linkedlist') b = dict

Re: How can I handle the char immediately after its input, without waiting an endline?

2008-10-25 Thread Lie Ryan
On Sat, 25 Oct 2008 15:27:32 +, Steven D'Aprano wrote: On Sat, 25 Oct 2008 16:30:55 +0200, Roel Schroeven wrote: Steven D'Aprano schreef: I can't think of any modern apps that use one character commands like that. One character plus a modifier (ctrl or alt generally) perhaps, but even

Re: PIL: Getting a two color difference between images

2008-10-25 Thread Lie Ryan
Kevin D. Smith: What I want is a two color output image: black where the image wasn't different, and white where it was different. Use the ImageChops.difference, which would give a difference image. Then map all colors to white except black using Image.point() --

Re: Consequences of importing the same module multiple times in C++?

2008-10-25 Thread Lie Ryan
On Fri, 24 Oct 2008 12:23:18 -0700, Robert Dailey wrote: Hi, I'm currently using boost::python::import() to import Python modules, so I'm not sure exactly which Python API function it is calling to import these files. I posted to the Boost.Python mailing list with this question and they

Re: Ordering python sets

2008-10-25 Thread Lie Ryan
On Sat, 25 Oct 2008 18:20:46 -0400, Terry Reedy wrote: Lie Ryan wrote: anotherrandommusing Since python is dynamic language, I think it should be possible to do something like this: a = list([1, 2, 3, 4, 5], implementation = 'linkedlist') For this to work, the abstract list would

Re: Ordering python sets

2008-10-25 Thread Lie Ryan
On Sat, 25 Oct 2008 18:20:46 -0400, Terry Reedy wrote: Lie Ryan wrote: anotherrandommusing Since python is dynamic language, I think it should be possible to do something like this: a = list([1, 2, 3, 4, 5], implementation = 'linkedlist') For this to work, the abstract list would

Re: Why can't I assign a class method to a variable?

2008-10-26 Thread Lie Ryan
On Wed, 22 Oct 2008 12:34:26 -0400, ed wrote: I'm trying to make a shortcut by doing this: t = Globals.ThisClass.ThisMethod Calling t results in an unbound method error. Is it possible to do what I want? I call this method in hundreds of locations and I'm trying to cut down on the

Re: How can I handle the char immediately after its input, without waiting an endline?

2008-10-26 Thread Lie Ryan
On Sun, 26 Oct 2008 09:23:41 +, Duncan Booth wrote: Lie Ryan [EMAIL PROTECTED] wrote: And as far as I know, it is impossible to implement a press any key feature with python in a simple way (as it should be). press any key is a misfeature at the best of times. Quite apart from

Re: Ordering python sets

2008-10-26 Thread Lie Ryan
On Sun, 26 Oct 2008 00:53:18 +, Steven D'Aprano wrote: [...] And how do you find an arbitrary object's creation point without searching the project's source code? How is it better using the current way? Asking the .implementation field isn't much harder than asking the type (), and is much

Re: Ordering python sets

2008-10-26 Thread Lie Ryan
On Sat, 25 Oct 2008 21:50:36 -0400, Terry Reedy wrote: Lie Ryan wrote: On Sat, 25 Oct 2008 18:20:46 -0400, Terry Reedy wrote: Then why do you object to current mylist = linkedlist(data) and request the harder to write and implement mylist = list(data, implementation

Re: Exact match with regular expression

2008-10-26 Thread Lie Ryan
On Sun, 26 Oct 2008 17:51:29 +0100, Mr.SpOOn wrote: Hi, I'd like to use regular expressions to parse a string and accept only valid strings. What I mean is the possibility to check if the whole string matches the regex. So if I have: p = re.compile('a*b*') I can match this:

  1   2   3   4   5   6   7   8   >