RE: Testing for an empty dictionary in Python

2008-03-23 Thread Ryan Ginstrom
ict_is_empty(D): for k in D: return False return True >>> dict_is_empty(dict(a=1)) False >>> dict_is_empty({}) True Regards, Ryan Ginstrom -- http://mail.python.org/mailman/listinfo/python-list

RE: Breaking the barrier of a broken paradigm... part 1

2008-03-24 Thread Ryan Ginstrom
bout for starters: import os for line in open("/etc/passwd"): user, _pwd = line.split(":") user_home = os.path.join("/expirt/home", user) > try: > os.makedirs('usrHome' ) > except Exception, e: > pr

RE: Breaking the barrier of a broken paradigm... part 1

2008-03-25 Thread Ryan Ginstrom
is has the benefit of allowing me to test create_user_dirs without touching the file system (by passing in a list of lines). Regards, Ryan Ginstrom -- http://mail.python.org/mailman/listinfo/python-list

Common path all PyObjects take on destruction?

2009-01-09 Thread Ryan Stutsman
I've added a field to all PyObjects in the interpreter which is of type PyObject*. Most of the time this pointer is NULL but occassionally I want to track some information in there. The problem I'm running into is that I can add a reference to a PyObject inside any of my PyObjects, but it seems

Embedding Python with non-filesystem code source?

2009-01-13 Thread Ryan Oltman
er way to setup the PyEval_CallObject that would allow this capability? Ryan Oltman -- http://mail.python.org/mailman/listinfo/python-list

Re: I'm a python addict !

2009-01-24 Thread Lie Ryan
On Fri, 23 Jan 2009 19:58:09 -0700, Linuxguy123 wrote: > I just started using python last week and I'm addicted. you need to try this: import antigravity http://xkcd.com/353/ -- http://mail.python.org/mailman/listinfo/python-list

Re: USB in python

2009-01-26 Thread Lie Ryan
On Fri, 23 Jan 2009 18:56:38 +1100, Astan Chee wrote: > Diez B. Roggisch wrote: >>> >>> >> If all you need is on-off - why can't you just use a switch? >> >> >> > Because I want to control the on-off the device using a computer and > write software for it (which I am confident I can do i

Re: USB in python

2009-01-27 Thread Lie Ryan
On Mon, 26 Jan 2009 11:08:48 -0600, Unknown wrote: > On 2009-01-26, Lie Ryan wrote: > >> How about (a crazy idea) using the audio jack out? (DISCLAIMER: Little >> Hardware Experience). High pitched sound (or anything in sound-ology >> that means high voltage) means

Re: practical limits of urlopen()

2009-01-27 Thread Lie Ryan
On Sat, 24 Jan 2009 09:17:10 -0800, webcomm wrote: > Hi, > > Am I going to have problems if I use urlopen() in a loop to get data > from 3000+ URLs? There will be about 2KB of data on average at each > URL. I will probably run the script about twice per day. Data from > each URL will be saved

Re: can multi-core improve single funciton?

2009-02-10 Thread Lie Ryan
On Tue, 10 Feb 2009 14:28:15 +0800, oyster wrote: > I mean this > [code] > def fib(n): > if n<=1: > return 1 > return fib(n-1)+fib(n-2) > > useCore(1) > timeit(fib(500)) #this show 20 seconds > > useCore(2) > timeit(fib(500)) #this show 10 seconds [/code] > > Is it possible? >

Re: Import without executing module

2009-02-10 Thread Lie Ryan
On Tue, 03 Feb 2009 20:08:34 -0800, Stephen Hansen wrote: > There is no need to try to make sure something is > executed/compiled only once in Python like you may want to do in C. > Every module is only ever compiled once: if you import it ten times in > ten different places only the first will co

Re: "Byte" type?

2009-02-14 Thread Lie Ryan
On Sat, 14 Feb 2009 22:10:41 -0800, John Nagle wrote: > >>> xx = b'x' Isn't this creating a regular byte? Shouldn't creation of bytearray be: >>> xx = bytearray(b'x') -- http://mail.python.org/mailman/listinfo/python-list

Re: Python interface to ODF documents?

2009-02-16 Thread Lie Ryan
On Sun, 15 Feb 2009 22:03:25 +0200, Dotan Cohen wrote: > Is there a Python interface to ODF documents? I'm thinking of something > that will import, for example, an ADS spreadsheet into a > multidimensional array (including formulas and formatting) and let me > manipulate it, then save it back. >

Re: How to convert between Japanese coding systems?

2009-02-19 Thread Lie Ryan
On Thu, 19 Feb 2009 15:28:12 +0900, Dietrich Bollmann wrote: > Hi, > > Are there any functions in python to convert between different Japanese > coding systems? If I'm not mistaken, the email standard specifies that only 7-bit ASCII- encoded bytes can be transported safely and reliably. The high

Re: Regular expression bug?

2009-02-20 Thread Lie Ryan
On Thu, 19 Feb 2009 13:03:59 -0800, Ron Garret wrote: > In article , > Peter Otten <__pete...@web.de> wrote: > >> Ron Garret wrote: >> >> > I'm trying to split a CamelCase string into its constituent >> > components. >> >> How about >> >> >>> re.compile("[A-Za-z][a-z]*").findall("fooBarBaz")

Re: end of print = lower productivity ?

2008-11-30 Thread Lie Ryan
On Sat, 2008-11-29 at 17:51 -0600, Tim Chase wrote: > >> It's not so much "ridiculous" as a failure of your editor to > >> assist you. In Vim (my editor-of-choice), I'd do something > >> like > > > > seriously, I don't think anyone in Windows uses vim > > Are you just guessing, or do you have an

Re: end of print = lower productivity ?

2008-12-01 Thread Lie Ryan
On Mon, 2008-12-01 at 09:46 -0600, Tim Chase wrote: > > For a proof, let's see what Google has to say about this: > > "Windows text editor". Vim is on page 3, near the turning > > point where nobody is talking about text-editor anymore and > > more about text-editor reviews. Even worse is Emacs, on

Re: Brain going crazy with recursive functions

2008-12-07 Thread Lie Ryan
On Sat, 06 Dec 2008 23:33:35 -0800, 5lvqbwl02 wrote: > I'm trying to solve the 9-tile puzzle using as functional an approach as > possible. I've recently finished reading SICP and am deliberately > avoiding easy python-isms for the more convoluted scheme/functional > methods. The following funct

Re: tabs and spaces in py3k

2008-12-07 Thread Lie Ryan
On Sun, 07 Dec 2008 20:51:50 -0800, rurpy wrote: > Do the Py3k docs need correction? If I were the maintainer of the parser, I'd add something like this: tab_width = random.randint(0, 1000) -- http://mail.python.org/mailman/listinfo/python-list

Re: Guido's new method definition idea

2008-12-07 Thread Lie Ryan
On Sun, 07 Dec 2008 20:56:40 +, I V wrote: > So, if we want Python to the programming language of choice for Lacanian > psychoanalysts, perhaps we should adopt the symbol "$" (or even, with > Python 3's support for unicode identifiers, S followed by U+0388) > instead of "self." Is that suppos

Re: Guido's new method definition idea

2008-12-07 Thread Lie Ryan
On Sun, 07 Dec 2008 12:57:27 +0100, News123 wrote: > Lie wrote: >> On Dec 7, 1:02 am, News123 <[EMAIL PROTECTED]> wrote: >>> What would be interesting would be some syntactical sugar to get rid >>> of the 'self' (at least in the code body). >>> >>> example: >>> class C: >>> class_elements a,b,

Re: Guido's new method definition idea

2008-12-08 Thread Lie Ryan
On Sun, 07 Dec 2008 18:27:21 +0100, Andreas Waldenburger wrote: > On Sat, 6 Dec 2008 23:21:04 -0800 (PST) Lie <[EMAIL PROTECTED]> wrote: > >> I think we have to test this on newbies. [snip] >> > Now that's talking like a programmer! > > Ideas on how such a survey could be conducted? Anyone? >

Re: infering the number of args a function takes at runtime

2008-12-08 Thread Lie Ryan
On Mon, 08 Dec 2008 02:40:03 -0800, sniffer wrote: > On Dec 8, 9:39 am, sniffer <[EMAIL PROTECTED]> wrote: >> hi all, >> i am a python newbie, in a project currently doing i need to find out >> the number of arguments that a function takes at runtime.? Is this >> possible ,if so how do i do this,i

Re: Is 3.0 worth breaking backward compatibility?

2008-12-09 Thread Lie Ryan
On Sun, 07 Dec 2008 21:48:46 +, Tim Rowe wrote: > 2008/12/7 walterbyrd <[EMAIL PROTECTED]>: >> IMO: breaking backward compatibility is a big deal, and should only be >> done when it is seriously needed. >> >> Also, IMO, most of, if not all, of the changes being made in 3.0 are >> debatable, at

Re: Guido's new method definition idea

2008-12-09 Thread Lie Ryan
On Mon, 08 Dec 2008 20:55:16 +, Arnaud Delobelle wrote: > [EMAIL PROTECTED] writes: > >> class C: >> def createfunc(self): >> def self.func(arg): >> return arg + 1 >> >> Or, after the class definition is done, to extend it dynamically: >> >> def C.method(self, arg): >>

Re: Is 3.0 worth breaking backward compatibility?

2008-12-09 Thread Lie Ryan
On Tue, 09 Dec 2008 16:10:08 -0500, Albert Hopkins wrote: > On Tue, 2008-12-09 at 20:56 +, Lie Ryan wrote: >> Actually I noticed a tendency from open-source projects to have slow >> increment of version number, while proprietary projects usually have >> big >> vers

Re: Is 3.0 worth breaking backward compatibility?

2008-12-10 Thread Lie Ryan
On Tue, 09 Dec 2008 17:25:59 -0500, Benjamin Kaplan wrote: > On Tue, Dec 9, 2008 at 3:56 PM, Lie Ryan <[EMAIL PROTECTED]> wrote: > >> On Sun, 07 Dec 2008 21:48:46 +, Tim Rowe wrote: >> >> > >> > But that's what a major release number does for

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Lie Ryan
On Fri, 12 Dec 2008 04:58:36 -0800, feba wrote: > Actually, I have gedit set to four spaces per tab. I have no reason why > it's showing up that large on copy/paste, but the file itself is fine. You've set gedit to _show tabs_ as four spaces, but not to substitute tabs with four spaces. Go to g

Re: (Very Newbie) Problems defining a variable

2008-12-12 Thread Lie Ryan
On Fri, 12 Dec 2008 09:50:43 -0800, Dennis Lee Bieber wrote: > On Fri, 12 Dec 2008 03:42:55 -0800 (PST), feb...@gmail.com declaimed the > following in comp.lang.python: > >> #!/usr/bin/python >> #Py3k, UTF-8 >> >> bank = int(input("How much money is in your account?\n>>")) target = >> int(input(

Re: Testing against different versions of Python

2008-12-12 Thread Lie Ryan
On Fri, 12 Dec 2008 14:42:24 -0500, mercado wrote: > What is the best way to go about testing against different versions of > Python? For example, I have 2.5.2 installed on my machine (Ubuntu Hardy > 8.04), and I want to test a script against 2.5.2 and 2.5.1 (and possibly > other versions as well

Re: Removing None objects from a sequence

2008-12-12 Thread Lie Ryan
On Fri, 12 Dec 2008 11:50:38 -0500, Steve Holden wrote: > Kirk Strauser wrote: >> At 2008-12-12T15:51:15Z, Marco Mariani writes: >> >>> Filip Gruszczyński wrote: >>> I am not doing it, because I need it. I can as well use "if not elem is None", >> >>> I suggest "if elem is not None",

Re: Interface & Implementation

2008-12-12 Thread Lie Ryan
On Fri, 12 Dec 2008 16:07:26 +0530, J Ramesh Kumar wrote: > Hi, > > I am new to python. I require some help on implementing interface and > its implementation. I could not find any sample code in the web. Can you > please send me some sample code which is similar to the below java code > ? Thanks

Re: Python 3.0 crashes displaying Unicode at interactive prompt

2008-12-13 Thread Lie Ryan
On Sat, 13 Dec 2008 14:09:04 -0800, John Machin wrote: > On Dec 14, 8:07 am, "Chris Rebert" wrote: >> On Sat, Dec 13, 2008 at 12:28 PM, John Machin >> wrote: >> >> > Python 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32 bit >> > (Intel)] on win32 >> > Type "help", "copyright", "credits

Re: [OT] stable algorithm with complexity O(n)

2008-12-14 Thread Lie Ryan
On Sat, 13 Dec 2008 19:17:41 +, Duncan Booth wrote: > "Diez B. Roggisch" wrote: > >> David Hláčik schrieb: >>> Hi guys, >>> >>> i am really sorry for making offtopic, hope you will not kill me, but >>> this is for me life important problem which needs to be solved within >>> next 12 hours

Re: Looking for the best way to translate an idiom

2008-12-14 Thread Lie Ryan
On Sun, 14 Dec 2008 09:51:03 -0800, Paul Moore wrote: > On 14 Dec, 16:22, Bruno Desthuilliers > wrote: >> if you only want the first returned value, you can just apply a slice: >> >> def f(): >>     return 1,2,3 >> >> a = f()[0] + 1 > > Hmm, true. I'm not sure it's any less ugly, though :-) >

Re: Removing None objects from a sequence

2008-12-14 Thread Lie Ryan
On Fri, 12 Dec 2008 22:55:20 +, Steven D'Aprano wrote: > On Fri, 12 Dec 2008 21:18:36 +0000, Lie Ryan wrote: >> Personally, I'd prefer VB's version: >> foo IsNot bar >> >> or in pseudo-python >> foo isnot bar >> >> since tha

Re: Removing None objects from a sequence

2008-12-14 Thread Lie Ryan
On Mon, 15 Dec 2008 03:21:21 +, Steven D'Aprano wrote: > On Mon, 15 Dec 2008 02:11:10 +0000, Lie Ryan wrote: > >>> So given the normal precedence rules of Python, there is no ambiguity. >>> True, you have to learn the rules, but that's no hardship. >>

Re: [OT] stable algorithm with complexity O(n)

2008-12-14 Thread Lie Ryan
On Mon, 15 Dec 2008 01:48:43 +, Steven D'Aprano wrote: > Some things really don't have a solution, no matter how much power of > positive thinking you apply to it. Some may, only not with the current understanding of the universe. Well, I agree that there are a few things that is straight ou

Re: alt.possessive.its.has.no.apostrophe

2008-12-15 Thread Lie Ryan
On Mon, 15 Dec 2008 11:53:40 -0800, Carl Banks wrote: > > (...For that matter, if the rule had been, "Never augment your words > spelling with an apostrophe", it would have really simplified > things) Th next dae, wee aul wil bee speling liek this -- http://mail.python.org/mailman/listinfo/

Re: Structure using whitespace vs logical whitespace

2008-12-16 Thread Lie Ryan
On Mon, 15 Dec 2008 08:29:31 -0800, cmdrrickhun...@yaho.com wrote: > I've been trying to search through the years of Python talk to find an > answer to this, but my Googlefu is weak. > > In most languages, I'll do something like this > > xmlWriter.BeginElement("parent"); > xmlWriter.BeginEle

Re: Generator slower than iterator?

2008-12-16 Thread Lie Ryan
On Tue, 16 Dec 2008 12:07:14 -0300, Federico Moreira wrote: > Hi all, > > Im parsing a 4.1GB apache log to have stats about how many times an ip > request something from the server. > > The first design of the algorithm was > > for line in fileinput.input(sys.argv[1:]): > ip = line.split()[

Re: Generator slower than iterator?

2008-12-16 Thread Lie Ryan
On Tue, 16 Dec 2008 12:07:14 -0300, Federico Moreira wrote: > Hi all, > > Im parsing a 4.1GB apache log to have stats about how many times an ip > request something from the server. > > The first design of the algorithm was > > for line in fileinput.input(sys.argv[1:]): > ip = line.split()[

Re: print to console without a line break

2008-12-23 Thread Lie Ryan
On Tue, 23 Dec 2008 11:50:59 +0100, Qian Xu wrote: > Hello All, > > Is it possible to print something to console without a line break? > > I tried: > sys.stdout.write("Testing something ...") // nothing will be printed > time.sleep(1) > sys.stdout.write("done\n") // now, the whole string w

Re: Python's popularity

2008-12-23 Thread Lie Ryan
On Mon, 22 Dec 2008 21:05:22 -0800, r wrote: > On Dec 22, 10:09 pm, Ben Kaplan wrote: >> That's just because most of us don't say anything unless we have >> something useful to say. We prefer to let the experts answer the >> questions, but we read the threads so we can benefit from them. > > OK

Re: string in files

2008-12-30 Thread Lie Ryan
On Tue, 30 Dec 2008 11:53:17 +0100, Glauco wrote: >> thanks brother >> i mean how do i particularly assign (u = this) >> (y = is) >> in the strings up there. i have been able to split strings with any >> character sign. >> >> > > If i'm not wrong this is

Re: Why not Ruby?

2009-01-02 Thread Ryan McCoskrie
Xah Lee wrote: > Q: Do you condemn Ruby? > > No. I think it's reasonably elegant, but today there are too many > languages, so Ruby don't particularly standout for me. Many of them, > are arguably quite more elegant and powerful than Ruby. There is one thing that Ruby is exceptionally good for

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]) >>> ast.li

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). >> >http://projecteuler.ne

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 ov

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. > > T

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 >> prog

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, e

socket programming (client-server) error

2008-10-22 Thread ryan fox
i have implemented a small client server model to do file transfer over a LAN network. It work with some machines on the network and on others it doesnt. when i run the server.py file in some machine then it pops up a windows security alert. The message is as follows: Do you want to keep bl

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

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 th

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. >

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 abou

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 y

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? > > > As Python becomes accepted for more and more "serious" projects some > more data structures can eventually be added to th

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)} > > Ma

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 +0000, Lie Ryan wrote: > >>>>> I want to write something that handle every char immediately after >>>>> its input. Then tehe user don't need to ty

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.

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 +0000, Lie Ryan wrote: > >> >> Since python is dynamic language, I think it should be possible to do >> something like this: >> >> a = list([1, 2, 3, 4, 5], im

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, >

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() -- http://mail.python.org

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 th

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: > > >> >> 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') &g

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: > > >> >> 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') &g

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

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

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

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 thi

Re: Ordering python sets

2008-11-01 Thread Lie Ryan
On Mon, 27 Oct 2008 13:18:43 -0700, bearophileHUGS wrote: > So I don't accept so much different data structures to have the > same name You need to adjust the current mindset slightly (but in an important way to understand the "why" behind this idea). The current notion is: list and dict is a

Re: Function Memory Usage

2008-11-01 Thread Lie Ryan
On Fri, 31 Oct 2008 18:41:58 +, Paulo J. Matos wrote: > Hi all, > > What's the best way to know the amount of memory allocated by a function > and the time it took to run? While the latter is simple to implement > using a wrapper function, the former is striking me as something that > needs t

Re: Windows DOS box redirection

2008-11-03 Thread Lie Ryan
On Fri, 31 Oct 2008 18:35:25 +0100, Stef Mientki wrote: > Bill McClain wrote: >> On 2008-10-31, Tim Golden <[EMAIL PROTECTED]> wrote: >> >>> You've got a few options. >>> >>> >> Ok, thanks! >> >> It is a small hobbyist community. I'll just document it and tell them >> "life is hard fo

Re: Ordering python sets

2008-11-04 Thread Lie Ryan
On Sun, 02 Nov 2008 02:08:37 +, Steven D'Aprano wrote: > On Sat, 01 Nov 2008 18:58:59 +, Tim Rowe wrote: > >> 2008/10/27 <[EMAIL PROTECTED]>: >>> Lie Ryan: >>> >>>>Oh no, the two dict implementation would work _exactly_

Re: Are .pyc files portable?

2008-11-09 Thread Lie Ryan
On Fri, 07 Nov 2008 18:36:41 -0800, Roy Smith wrote: > I'm using Python as part of a test fixture for a large (mostly C++) > software project. We build on a lot of different platforms, but Solaris > is a special case -- we build on Solaris 8, and then run our test suite > on Solaris 8, 9, and 10.

Re: Custom keyboard shortcuts

2008-11-09 Thread Lie Ryan
On Sun, 09 Nov 2008 06:15:02 -0800, aud2008 wrote: > Nov 9 2008,9.14PM<[EMAIL PROTECTED]> to be or not to be... what is the question. -- http://mail.python.org/mailman/listinfo/python-list

PP3E error

2008-11-15 Thread ryan payton
How do I fix the PP3E and PP2E errors in Programming Python 3rd Edition? -- http://mail.python.org/mailman/listinfo/python-list

PP3E error

2008-11-16 Thread ryan payton
I still need help with a PP3E error I am getting in my 'PyEdit' program I have from Progamming Python 3rd Edition. I am working on a mac and the error is coming from: from PP3E.Gui.Tools.guimaker import * -- http://mail.python.org/mailman/listinfo/python-list

Re: PP3E error

2008-11-17 Thread ryan payton
sorry: Traceback (most recent call last): File "texteditor.py", line 460, in class TextEditorMain(TextEditor, GuiMakerWindowMenu): NameError: name 'GuiMakerWindowMenu' is not defined On Nov 16, 2008, at 10:14 PM, Gabriel Genellina wrote: En Mon, 17 Nov 2008 03:32:3

Design By Contract in Python

2008-11-17 Thread Ryan Freckleton
Implementation:http://pastebin.com/f368d5396 Example class: http://pastebin.com/f51be54be Thanks, Ryan Freckleton -- http://mail.python.org/mailman/listinfo/python-list

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: > > > > > $ > PID > > > .. > ... > > C

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 XQuer

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 functi

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" > wrote: >> En Sat, 28 Feb 2009 14:34:15 -0200, 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 __Main__.py not found in Co

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: >> >> >> >> the value foo will be picked up for sure. But, if there is a space: >> >>

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".

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 > escribió: >> On Sun, Mar 1, 2009 at 8:54 AM, Gabriel Genellina >> wrote: >>> En Sun, 01 Mar 2009 13:20:28 -0200, John O'Hagan >>> >>> escribió: >>> Inspired by some recent threads here about using classes to exten

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: http://nedbatchelder.com/text/pyt

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)) * in argument unpacking is not an operat

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 new

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 is

<    1   2   3   4   5   6   7   8   9   10   >