How to Mock a mongodb

2015-02-07 Thread Xavier Pegenaute
Dear, I am trying to mock the use of a mongo db and I am having some trouble. Appears that I am not able to return a desired value from mongo.find().count(). I made a proof of concept to try to reduce complexity of the real problem. You can find the code which is going to be tested in [1], a

How to Mock a mongodb

2015-02-07 Thread Xavier Pegenaute
Dear, I am trying to mock the use of a mongo db and I am having some trouble. Appears that I am not able to return a desired value from mongo.find().count(). I made a proof of concept to try to reduce complexity of the real problem. You can find the code which is going to be tested in [1], a

[ANN] pdb-clone 1.9 - a fast clone of pdb with the remote debugging and attach features

2014-10-15 Thread Xavier de Gaye
pdb-clone 1.9 has been released at Pypi: https://pypi.python.org/pypi/pdb-clone Features: * Improve significantly pdb performance. With breakpoints, pdb-clone runs just above the speed of the interpreter while pdb runs at 10 to 100 times the speed of the interpreter. * Extend pdb with remo

Re: [OT] Awesome bug of the week

2014-08-13 Thread Xavier Ho
Haha! On 14 August 2014 14:54, Steven D'Aprano wrote: > Nothing to do with Python, but awesome: "OpenOffice won't print on > Tuesdays". > > https://bugs.launchpad.net/ubuntu/+source/cupsys/+bug/255161/comments/28 > > > > -- > Steven > -- > https://mail.python.org/mailman/listinfo/python-list >

Re: All-numeric script names and import

2014-05-22 Thread Xavier de Gaye
On 05/22/2014 12:32 PM, Xavier de Gaye wrote: > import 1.py as module_1 on Python 2.7 (module_1 is not inserted in sys.modules): > > >>> import imp > >>> module_1 = imp.new_module('module_1') > >>> execfile('1.py', module_1

Re: All-numeric script names and import

2014-05-22 Thread Xavier de Gaye
y as module_1 on Python 2.7 (module_1 is not inserted in sys.modules): >>> import imp >>> module_1 = imp.new_module('module_1') >>> execfile('1.py', module_1.__dict__) >>> del module_1.__dict__['__builtins__'] Xavier -- https://mail.python.org/mailman/listinfo/python-list

ANN: pdb-clone 1.6 - a fast clone of pdb with the remote debugging and attach features

2014-05-19 Thread Xavier de Gaye
pdb-clone 1.6 has been released at Pypi: https://pypi.python.org/pypi/pdb-clone Features: * Improve significantly pdb performance. With breakpoints, pdb-clone runs just above the speed of the interpreter while pdb runs at 10 to 100 times the speed of the interpreter. * Instrument the code

Re: Functional vs. Object oriented API

2013-04-10 Thread Xavier Ho
Hi Max, In Python, we prefer readability over anything else. The simpler you can write it, the better it can be understood. That said, I've never considered using (i, j, k) as a vector component before. I've always done something akin to: >>> vector = Vector(2, 4, 6) >>> print (vector.normaliz

Re: how do you make a loop run in reverse?

2013-03-26 Thread Xavier Ho
There is a built-in function that reverses an iterable. Have a look at the documentation. xav On 27 March 2013 10:59, wrote: > So i have a set of for loops that create this : > > *** > *** *** *** *** *** *** *** > *** *** *** *** ***

Re: How to quickly set up a multithreaded server that can handle http file post.

2013-03-11 Thread Xavier L.
On 13-03-11 10:42 AM, Shiyao Ma wrote: Today I come across a problem. Basically, my need is that I want to launch a http server that can not only support get but also support post (including post file). My first idea is to use -m http.sever. However, it only supports get. Later I find some one ex

Re: Recording live video stream from IP camera issue

2013-02-17 Thread Xavier Ho
Hi Sam, Did you compile your OpenCV with gstreamer? That's where I'd look first. Cheers, Xav On 18 February 2013 01:15, Sam Berry wrote: > Hi Xav, > > Iv been looking into OpenCV, i can easily stream my laptops webcam using > this code. > > import cv2 > > cv2.namedWindow("preview") > > vc =

Re: Recording live video stream from IP camera issue

2013-02-06 Thread Xavier Ho
On 7 February 2013 00:12, Sam Berry wrote: > Hi, > > This is for a university project. > > My issue is that i have built an App using pythons Kivy module, and i need > to be able to stream and record from an IP camera upon request. > > I have just used the VLC.exe to stream the video feed. But it

Fwd: Recording live video stream from IP camera issue

2013-02-06 Thread Xavier Ho
On 6 February 2013 23:12, Sam Berry wrote: > I have no vast knowledge of python, but i came across this code to capture > video from my IP camera > > This code works, however when i try to playback the .avi file in VLC > player... I've been working with several IP cameras with Python and OpenCV

Python 2 multiprocessing examples in docs.python.org

2013-01-31 Thread Xavier Ho
Hey all, I ran the example code on multiprocessing. On the "Pool example", an assertion failed with "testing garbage collection". Traceback (most recent call last): File "test.py", line 314, in test() File "test.py", line 295, in test assert not worker.is_alive() AssertionError The

Re: 3.2 can't extract tarfile produced by 2.7

2012-12-26 Thread Xavier Combelle
You probably want to write of = open("DUMP.tbz", "wb") and gf =open("DUMP.tbz", "rb") -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with Python/ArcPy

2012-12-12 Thread Xavier Ho
You can always try http://stackoverflow.com/search?q=ArcPY, or post your question there. Cheers, Xav On 13 December 2012 08:07, Michelle Couden wrote: > Does anyone know of a website or forum where there is help for ArcPY > (Python) programmers? ESRI’s (GIS) resource center Forums are very b

Re: Batching HTTP requests with httplib (Python 2.7)

2012-09-17 Thread Xavier Combelle
instead of Le 14/09/2012 12:56, Dwight Hutto a écrit : service_num_list = [num for num in range(0,5)] for service_num in service_num_list: eval("web_service_call%i(%i)" % (service_num,service_num)) service_num_list = [num for num in range(0,5)] for service_num in service_num_list:

Re: Creating a simple CGI Script

2012-08-02 Thread Xavier Combelle
In server.py you made a mistake in the declaration of the cgi directory it should be handler.cgi_directories = ["/"] Le 02/08/2012 20:20, Smaran Harihar a écrit : Hi, I am trying to create a simple CGI Script and following this tutorials

Re: Upgrading from 2.7 to 3.x

2012-04-25 Thread Xavier Ho
What operating system are you running? Cheers, Xav On 26 April 2012 13:08, deuteros wrote: > I'm fairly new to Python I have version 2.7 installed on my computer. > However > my professor wants us all to use the latest version of Python. How do I go > about upgrading? Do I just install the ne

Re: Comparing None and ints

2012-01-16 Thread Xavier Ho
Good to see Python3 got rid of that confusion :] Cheers, Xav On 17 January 2012 16:50, Chris Angelico wrote: > On Tue, Jan 17, 2012 at 5:47 PM, Xavier Ho wrote: > > What was the rationale behind this design? Specifically, (None < 0) == > True > > and

Comparing None and ints

2012-01-16 Thread Xavier Ho
Hello, I discovered this strange property by accident: Python 2.7.2 (default, Nov 21 2011, 17:25:27) [GCC 4.6.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> None < 0 True >>> None == 0 False >>> None > 0 False >>> int(None) Traceback (most recent call last

Re: Execute a command on remote machine in python

2011-11-15 Thread Xavier Ho
It sounds like Fabric is what you're after. We use it at work and it's the best thing since ssh. ;] http://docs.fabfile.org/en/1.3.2/index.html (Actually, it uses ssh internally and allows you to do remote shell-like programming in a pythonic fashion.) Cheers, Xav On 15 November 2011 22:04, R

Re: Fun python 3.2 one-liner

2011-03-29 Thread Xavier Ho
http://www.ideone.com/infch ^ Result of the below code On 29 March 2011 19:50, Raymond Hettinger wrote: > from collections import Counter > from itertools import product > > print('\n'.join('*'*(c//2000) for _,c in sorted(Counter(map(sum, > product(range(6), repeat=8))).items( > > > almost-n

how to read the last line of a huge file???

2011-01-26 Thread Xavier Heruacles
I have do some log processing which is usually huge. The length of each line is variable. How can I get the last line?? Don't tell me to use readlines or something like linecache... -- http://mail.python.org/mailman/listinfo/python-list

[ANN] Pyclewn: Vim as a front end to pdb

2010-12-05 Thread Xavier de Gaye
the instantaneous backtrace of all the threads, including those that are stuck in a deadlock. * Pdb is currently supported on unix platforms and requires the latest Vim version: Vim 7.3. Python3 is not supported yet. -- Xavier Les Chemins de Lokoti: http://lokoti.alwaysdata.net -- http

Re: How do I get the email address of the person who clicked the link in the email?

2010-12-04 Thread Xavier Ho
As a suggestion, you can auto-format your email link so that the email of the user is sent as part of the URL GET argument. Cheers, Xav On 5 December 2010 08:15, Zeynel wrote: > Hello, > > I am working with Google App Engine python version. The app sends an > email to the user with a link to a

how to go on learning python

2010-11-30 Thread Xavier Heruacles
I'm basically a c/c++ programmer and recently come to python for some web development. Using django and javascript I'm afraid I can develop some web application now. But often I feel I'm not good at python. I don't know much about generators, descriptors and decorators(although I can use some of it

Re: Python OGL package

2010-11-16 Thread Xavier Ho
Also try Pyglet, in combination of PyOpenGL. Cheers, Xav On 17 November 2010 04:36, Marc-Andre Belzile < marc-andre.belz...@autodesk.com> wrote: > Hi list, > > > > could someone recommend a good python ogl package (open source is > preferred) ? I found these ones so far: > > > > http://pyopengl

C++ comment in Javadoc style -> reStructuredText compiler?

2010-11-04 Thread Xavier Ho
Hey all, Apologies if I am posting this in the wrong list. Does anyone know of a good compiler for javadoc comment style into reStructuredText, for Sphinx to chew? Cheers, Xavier -- http://mail.python.org/mailman/listinfo/python-list

Re: What people are using to access this mailing list

2010-11-03 Thread Xavier Ho
Gmail. -Xav On 3 November 2010 18:02, John Bond wrote: > Hope this isn't too O/T - I was just wondering how people read/send to this > mailing list, eg. normal email client, gmane, some other software or online > service? > > My normal inbox is getting unmanageable, and I think I need to find

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-29 Thread Xavier Ho
Not sure why you use the for-else syntax without a break or continue. And I'm also not sure on the readability. -Xav on his Froyo On 29/10/2010 6:21 PM, "HEK" wrote: > On Oct 28, 6:16 pm, "cbr...@cbrownsystems.com" > wrote: >> It's clear but tedious to write: >> >> if 'monday" in days_off or "tu

Re: Pythonic way of saying 'at least one of a, b, or c is in some_list'

2010-10-28 Thread Xavier Ho
On 29 October 2010 15:50, Paul Rubin wrote: > John Nagle writes: > >d1 = set('monday','tuesday') > >days_off = set('saturday','sunday') > >if not d1.isdisjoint(days_off) :... > >This is cheaper than intersection, since it doesn't have to > > allocate and construct a set. It just

Re: factorial of negative one (-1)

2010-10-28 Thread Xavier Ho
On 29 October 2010 14:41, Bj Raz wrote: > > Since Python can't call functions, I would like to know if there is a work > around. > Python can't call functions? I'm sorry, but I may have misunderstood what you are trying to say. I'm not familiar with the mathematical definition of factorial, but

Re: How on Factorial

2010-10-28 Thread Xavier Ho
On 29 October 2010 00:13, Dave Angel wrote: > From the help: > > "The unary ~ (invert) operator yields the bitwise inversion of its plain or > long integer argument. The bitwise inversion of x is defined as -(x+1). It > only applies to integral numbers" > > Inverting the bits of a floating point

Re: How on Factorial

2010-10-28 Thread Xavier Ho
On 28 October 2010 23:52, Dave Angel wrote: > The ~- trick only works on two's complement numbers. I've worked on > machines in the past that used one's complement, and this wouldn't work > there. > > DaveA > I imagine this wouldn't work on floating point numbers either. Cheers, Xav -- http:/

Re: 'NoneType' object has no attribute 'bind'

2010-10-28 Thread Xavier Ho
On 28 October 2010 20:24, Alex wrote: > hi there, I keep getting the message in the Topic field above. > > Here's my code: > > self.click2=Button(root,text="Click Me").grid(column=4,row=10) > self.click2.bind("",self.pop2pop) > what am I doing wrong? > Try self.click2=Button(root,text="Click Me

Re: How on Factorial

2010-10-28 Thread Xavier Ho
On 27 October 2010 18:27, Arnaud Delobelle wrote: > True. It's far too verbose. I'd go for something like: > >f=lambda n:n<=0 or n*f(~-n) > > I've saved a few precious keystrokes and used the very handy ~- idiom! > Huh, I've never seen that one before. Seems to work on both positive and ne

Re: programming

2010-09-20 Thread Xavier Ho
On 20 September 2010 17:29, Xavier Ho wrote: > Secondly, that doesn't even compile. Nor does > > xDistance=eval(input("Distance to the stop sign (in feet): ")) > Just correcting myself here. It compiles, but generates an error when you give it a number, which still f

Re: programming

2010-09-20 Thread Xavier Ho
Okay, it looks like you're doing well. I'm just going through your second email now, and it seems many of my comments in the first email is irrelavent to you anymore, because you already knew how to do it. =] Let's have a look. Again, my reply is in Blue. . *And what I've attempted to do so far.

Re: programming

2010-09-20 Thread Xavier Ho
Thanks Jordan. My reply will be in Blue. I apologise if this ever gets hard to read, but it's beginning to. On 20 September 2010 16:51, Jordan Blanton wrote: > "And so he started on a module that estimated the length of a sine wave. > Here is what he wrote: " > ok. what is a module? A Python

Re: programming

2010-09-20 Thread Xavier Ho
On 20 September 2010 16:38, Jordan Blanton wrote: > Honestly, if I knew what was being said, then yes. I posted the directions > to the project and what I've done so far but I have no idea if what I'm > doing is right at all. > > Jordan, correct me if I'm mistaken, but you didn't post the directi

Re: programming

2010-09-19 Thread Xavier Ho
On 20 September 2010 16:25, Jordan Blanton wrote: > its not specific terms that i dont understand. its general directions. but > when i dont understand one or two key points in a sentence, its hard to > understand what the directions are telling me to do. Is it possible for you to share the sen

Re: programming

2010-09-19 Thread Xavier Ho
On 20 September 2010 15:46, Jordan Blanton wrote: > I am in a computer science class in which I am supposed to be creating a > program involving a sine wave and some other functions. I understand the > concept of the problem, but I don't understand any of the "lingo" being > used. The directions

Re: Down with tinyurl! (was Re: importing excel data into a python matrix?)

2010-09-19 Thread Xavier Ho
On 20 September 2010 07:59, Ken Watford > wrote: > > Not that I disagree with you, but you might find this helpful: > http://tinyurl.com/preview.php > -- > http://mail.python.org/mailman/listinfo/python-list > I don't think the OP wants a preview feature. The fact that you still have to go throu

Re: Very stupid question about a % symbol

2010-09-17 Thread Xavier Ho
On 17 September 2010 12:48, Terry Reedy wrote: > Doubling an escape char, whatever it is, is a common convention: > >>> print("Print a {{}} format string line this: {{{}}}".format(2)) > Print a {} format string line this: {2} > Wow. That's convoluted. Took me a minute to process. Cheers, Xav --

Re: Very stupid question about a % symbol

2010-09-16 Thread Xavier Ho
On 17 September 2010 01:25, J wrote: > Is there a better way to print a '%' in the string when also using > formating? > I believe %% will escape the % and prints it straight out. Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: Current install methodolgy eggs?

2010-09-12 Thread Xavier Ho
On 13 September 2010 08:40, Ben Finney > wrote: > Paul Watson writes: > > > What is the currently favored installation process for Python > > applications? > > ‘python ./setup.py install’, using the standard library's Distutils > library. > I thought it was python setup.py install or ./setup

Re: mutate dictionary or list

2010-09-07 Thread Xavier Ho
On 7 September 2010 22:05, Baba wrote: > > It would be great if someone could give me a brief explanantion of the > mutation concept. > In this case, to mutate is to change. If you must not mutate the list, you must not change it. In another words, reading from the list is fine. Writing to it i

Re: Minimum and Maximum of a list containing floating point numbers

2010-09-07 Thread Xavier Ho
On 7 September 2010 10:56, MRAB wrote: > > > Incidentally, there's a builtin function called 'input' so using it as > a variable name is a discouraged! :-) Right-o! Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: Minimum and Maximum of a list containing floating point numbers

2010-09-06 Thread Xavier Ho
On 7 September 2010 10:37, ceycey wrote: > I have a list like ['1.1881', '1.1881', '1.1881', '1.1881', '1.1881', > '1.1881', '1.1881', '1.1881', '1.1881', '1.1881', '1.7689', '1.7689', > '3.4225', '7.7284', '10.24', '9.0601', '9.0601', '9.0601', '9.0601', > '9.0601']. > How can I convert the

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Xavier Ho
2010/9/2 Alban Nona > Hello Xavier, working great ! thank you very much ! :p > Do you know by any chance if dictionnary can be sorted asthis: > Look at the sorted() global function in the Python API. ;] Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Xavier Ho
On 2 September 2010 02:49, Alban Nona wrote: > Well what Iam trying to generate is that kind of result: > > listn1=['ELM001_DIF', 'ELM001_SPC', 'ELM001_RFL', 'ELM001_SSS', > 'ELM001_REFR', 'ELM001_ALB', 'ELM001_AMB', 'ELM001_NRM', 'ELM001_MVE', > 'ELM001_DPF', 'ELM001_SDW', 'ELM001_MAT', 'ELM001_

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Xavier Ho
On 2 September 2010 01:11, Alban Nona wrote: > Hello, > > seems to have the same error with python. > In fact I was coding within nuke, a 2d compositing software (not the best) > unfortunately, I dont see how I can use dictionnary to do what I would like > to do. > Hello Alban, The reason it's

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Xavier Ho
On 2 September 2010 00:47, Alban Nona wrote: > Hello, > > So I figure out this night how to create automatically varibales via > vars(), the script seems to work, exept that where it should give me a list > like : > [ELM004_DIF,ELM004_SPC,ELM004_RFL,ELM004_SSS, ELM004_REFR, ELM004_ALB, > etc...]

Re: Dumb Stupid Question About List and String

2010-08-31 Thread Xavier Ho
On 1 September 2010 12:00, Alban Nona wrote: > @Xavier: ShaDoW, WorldPositionPoint (which is the same thing as > WordPointCloud passe) :) > Aha! That's what I was missing. Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: Dumb Stupid Question About List and String

2010-08-31 Thread Xavier Ho
On 1 September 2010 07:57, Alban Nona wrote: > listPass = ["DIF","SPC", "RFL", "SSS", "REFR", "ALB", "AMB", "NRM", "MVE", > "DPF", "SDW", "MAT", "WPP"] > Out of curiosity, could you briefly mention what "SDW" and "WPP" passes are? I've worked out the rest, and these two are riddling my brain. (

Re: meta-class troubles

2010-08-30 Thread Xavier Ho
Actually, scrape what I said. I think you need to have metaclass in the class statement, not just meta. -Xav On 31 August 2010 00:16, Xavier Ho wrote: > Ethan, are you trying to write the constructor in the class statement? > > Cheers, > Xav > > > On 31 August 2010 00:10

Re: meta-class troubles

2010-08-30 Thread Xavier Ho
Ethan, are you trying to write the constructor in the class statement? Cheers, Xav On 31 August 2010 00:10, Ethan Furman wrote: > Good Day! > > I am stuck... hopefully a few fresh pairs of eyes will spot what I am > missing. > > I have a metaclass, Traits, and two different testing files, test_

Re: palindrome iteration

2010-08-27 Thread Xavier Ho
One possible reason I can think of - "- exiting this loop means all compared chars were identical hence it is a palindrome and i return True" is probably incorrect reasoning. Think again. Also, you may consider posting your code in a way that preserves the whitespace characters. Cheers, Xav On

Re: Simple list problem that's defeating me!

2010-06-22 Thread Xavier Ho
On 23 June 2010 00:06, Neil Webster wrote: > Hi all, > > I've got a simple problem but it's defeated me and I was wondering if > somebody could point out where I'm going wrong or offer an alternative > solution to the problem? > > I have a list of lists such as [[a,2,3,4],[b,10,11,12], [a,2,3,4]]

Re: pythonize this!

2010-06-15 Thread Xavier Ho
On 15 June 2010 22:55, superpollo wrote: > Peter Otten ha scritto: > > superpollo wrote: >> >> goal (from e.c.m.): evaluate >>> 1^2+2^2+3^2-4^2-5^2+6^2+7^2+8^2-9^2-10^2+...-2010^2, where each three >>> consecutive + must be followed by two - (^ meaning ** in this context) >>> >> >> from iterto

Re: pythonize this!

2010-06-15 Thread Xavier Ho
On 15 June 2010 21:49, superpollo wrote: > goal (from e.c.m.): evaluate > 1^2+2^2+3^2-4^2-5^2+6^2+7^2+8^2-9^2-10^2+...-2010^2, where each three > consecutive + must be followed by two - (^ meaning ** in this context) > Obligatory one-liner: >>> sum((1, 1, 1, -1, -1)[(x-1) % 5] * x**2 for x in x

Re: a +b ?

2010-06-11 Thread Xavier Ho
2010/6/12 yanhua > hi,all! > it's a simple question: > input two integers A and B in a line,output A+B? > > this is my program: > s = input() > t = s.split() > a = int(t[0]) > b = int(t[1]) > print(a+b) > > but i think it's too complex,can anybody tell to slove it with less code. > -- > The reas

Re: What does this PyChecker warning mean?

2010-06-01 Thread Xavier Ho
On 1 June 2010 21:48, Leo Breebaart wrote: > > When fed the following code: > > def Foo(): > >class A(object): >def __init__(self): >pass > >class B(object): >def __init__(self): >pass > > PyChecker 0.8.18 warns: > > foo.py:9: Redefining attribute

Re: Question about permutations (itertools)

2010-05-31 Thread Xavier Ho
> >>> list(combinations_with_replacement('01',3)) > ('0', '0', '0') > ('0', '0', '1') > ('0', '1', '1') > ('1', '1', '1') > > Is it possible to get combinations_with_replacement to return numbers > rather than strings? (see above) > >>> list(combinations_with_replacement(range(0,2), 3)) [(0, 0, 0)

Re: reading help() - newbie question

2010-05-31 Thread Xavier Ho
On 31 May 2010 20:19, Payal wrote: > Hi, > I am trying to learn Python (again) and have some basic doubts which I > hope someone in the list can address. (English is not my first language and > I > have no CS background except I can write decent shell scripts) > > Welcome (back) to the Python-Lis

Re: Creating a single list

2010-05-29 Thread Xavier Ho
> # Insert into the list with slicing syntax. >column_title_list[2:3} = getproduct() > Sorry, that should have been [2:3]. Typing a bit too fast. -Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a single list

2010-05-29 Thread Xavier Ho
On 29 May 2010 23:24, Astley Le Jasper wrote: > def createlist(): >column_title_list = ( >("id",20,"integer"), >("companyname",50,"text"), >getproducts(), >

Re: A Friday Python Programming Pearl: random sampling

2010-05-29 Thread Xavier Ho
On 29 May 2010 06:44, Mark Dickinson wrote: > But I was struck by its beauty and > simplicity, and thought it deserved to be better known. > Wow, that took me at least 2 minutes to see its beauty as well. Nice find, Mark. Thanks for sharing. (Also, it's nice to see another SOer on Python-List a

Re: if, continuation and indentation

2010-05-27 Thread Xavier Ho
On 27 May 2010 23:26, Xavier Ho wrote: > Oh, one minor optimisation. You can put the last condition first > I take that back. You really can't, without using more parans or ifs. Apologies. -Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: if, continuation and indentation

2010-05-27 Thread Xavier Ho
On 27 May 2010 22:57, Jean-Michel Pichavant wrote: > One possible solution >> >> if ( >> width == 0 and >> height == 0 and >> color == 'red' and >> emphasis == 'strong' or >> highlight > 100 >> ): >> raise ValueError("sorry, you lose

Re: if, continuation and indentation

2010-05-27 Thread Xavier Ho
On 27 May 2010 22:57, Jean-Michel Pichavant wrote: > One possible solution > > if ( > width == 0 and > height == 0 and > color == 'red' and > emphasis == 'strong' or > highlight > 100 > ): > raise ValueError("sorry, you lose") > > But

Re: if, continuation and indentation

2010-05-27 Thread Xavier Ho
On 27 May 2010 22:22, HH wrote: >if (width == 0 and >height == 0 and >color == 'red' and >emphasis == 'strong' or >highlight > 100): >raise ValueError("sorry, you lose") > I've gotta say - I've bumped into this problem before, and I'm sure many other h

Re: where are the program that are written in python?

2010-05-22 Thread Xavier Ho
On Sun, May 23, 2010 at 3:35 PM, sturlamolden wrote: > Yes I know about PyOpenGL, but then there is the speed argument: From > C I can make epeated calls to functions like glVertex4f with minial > loss of efficacy. Calling glVertex4f from Python (e.g. PyOpenGL) would > give me the Python (and pos

Re: where are the program that are written in python?

2010-05-21 Thread Xavier Ho
On Fri, May 21, 2010 at 9:12 PM, Deep_Feelings wrote: > thankx for reply. > > from that list i have a feeling that python is acting only as "quick > and dirty work" nothing more ! > You might have just offended a lot of people on the list here Cheers, Xav -- http://mail.python.org/mailman

Re: __str__ for each function in a class

2010-05-19 Thread Xavier Ho
On 5/19/2010 1:14 AM, Vincent Davis wrote: > class C(object): >> def __init__(self, new): >> self.letter = dict(a=1,b=2,c=3, amin=np.amin) >> self.new = new >> self._x = None >> self._Y = None >> >> @property >> def x(self): >> """I'm the 'x' property.""

Re: help need to write a python spell checker

2010-05-18 Thread Xavier Ho
Yeah, most unis here commence in March, and the first semester usually finish in June, when the exams are. - Xav on his 'droid On 19/05/2010 2:21 PM, "Patrick Maupin" wrote: On May 14, 3:19 am, "harry k" wrote: > Write a spell checking tool that wil... Well, this has been educational. Both m

Re: Human word reader

2010-05-15 Thread Xavier Ho
On Sat, May 15, 2010 at 9:32 PM, timo verbeek wrote: > On May 15, 1:02 pm, timo verbeek wrote: > Place starts always with for > Okay, much better. Given that constraint, it looks like regular expression can do the job. I'm not very experienced with regex, though. \w* matches a whole word compo

Re: Human word reader

2010-05-15 Thread Xavier Ho
On Sat, May 15, 2010 at 9:12 PM, Xavier Ho wrote: > You need to have a very, very good set of heruistics and deterministic > functions to do that. > > "How do I get the position of a known word in a string if the length if > unknown?" > And this is what I get f

Re: Human word reader

2010-05-15 Thread Xavier Ho
On Sat, May 15, 2010 at 9:02 PM, timo verbeek wrote: > I'm planning to create a human word program > > > I need help with getting the useful information how do I get the place > if I don't now how long the string is? > > Boy, that is a very hard problem. Are the inputs restricted to anything? E

Re: help need to write a python spell checker

2010-05-15 Thread Xavier Ho
1) Welcome to Python-List! 2) Python-list doesn't like to do other people's homework. 3) What have you tried? Cheers, Xav On Fri, May 14, 2010 at 6:19 PM, harry k wrote: > Write a spell checking tool that will identify all misspelled word in a > text file using a provided dictionary. > > > Th

Re: Extract all words that begin with x

2010-05-10 Thread Xavier Ho
Have I missed something, or wouldn't this work just as well: >>> list_of_strings = ['2', 'awes', '3465sdg', 'dbsdf', 'asdgas'] >>> [word for word in list_of_strings if word[0] == 'a'] ['awes', 'asdgas'] Cheers, Xav On Mon, May 10, 2010 at 6:40 PM, Jimbo wrote: > Hello > > I am trying to find

Re: solve a newspaper quiz

2010-05-09 Thread Xavier Ho
On Sun, May 9, 2010 at 7:20 PM, superpollo wrote: > "if a b c are digits, solve ab:c=a*c+b" > Sorry, what does the notation ab:c mean? Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: can we change the variables with function

2010-05-09 Thread Xavier Ho
On Sun, May 9, 2010 at 6:19 PM, gopi krishna wrote: > Hi >can I change the variable in a function using the function > suppose > >>>def a(): > x=20 > can we change the variable using the function > Can you give us an example of how you'd like to "change the variable", in code, and show us wha

Re: Why list comprehension faster than for loop?

2010-05-09 Thread Xavier Ho
On Sun, May 9, 2010 at 6:20 PM, gopi krishna wrote: > Why list comprehension faster than for loop? > > Because Python optimises for certain special cases, when the number of iterations is predicable in a list comprehension. Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-ideas] division oddness

2010-05-06 Thread Xavier Ho
On Fri, May 7, 2010 at 12:14 PM, Chris Rebert wrote: > Personally, I find the following the most unintuitive: > divmod(-11, 3) == (-4, 1) > > So, we overshoot -11 and then add 1 to go back to the right place? > That violates my intuitive thought that abs((n//d)*d) <= abs(n) ought to > hold. > Ha

Re: [Python-ideas] division oddness

2010-05-06 Thread Xavier Ho
On Fri, May 7, 2010 at 11:13 AM, Chris Rebert wrote: > On Thu, May 6, 2010 at 5:43 PM, Mathias Panzenböck > wrote: > > Shouldn't by mathematical definition -x // y be the same as -(x // y)? > > I think this rather odd. Is there any deeper reason to this behaviour? I > > guess changing this will

Re: column selection

2010-05-06 Thread Xavier Ho
You need to ignore empty lines. for line in open('1.txt'): if len(line.strip()) == 0: continue columns = line.split() print columns[0], columns[2] Cheers, Xav On Thu, May 6, 2010 at 6:22 PM, mannu jha wrote: > Hi, > > I have few files like this: > > 24 ALA helix (helix_alph

Re: dynamic function add to an instance of a class

2010-04-29 Thread Xavier Ho
On Thu, Apr 29, 2010 at 5:55 PM, Richard Lamboj wrote: > > Hello, > > i want to add functions to an instance of a class at runtime. The added > function should contain a default parameter value. The function name and > function default paramter values should be set dynamical. > > Kind Regards, > >

Re: How to check what is holding reference to object

2010-04-27 Thread Xavier Ho
Michal, May I ask why do you care about the object's management? Let Python worry about that. What's your use case? -- http://mail.python.org/mailman/listinfo/python-list

Re: Engineering numerical format PEP discussion

2010-04-25 Thread Xavier Ho
On Mon, Apr 26, 2010 at 3:39 PM, Chris Rebert wrote: > "The conversion **exactly follows the rules for conversion to > scientific numeric string** except in the case of finite numbers > **where exponential notation is used.**" > Well, then maybe the conversion doesn't exactly follow the rules, i

Re: Engineering numerical format PEP discussion

2010-04-25 Thread Xavier Ho
On Mon, Apr 26, 2010 at 3:19 PM, Chris Rebert wrote: > Apparently either you and the General Decimal Arithmetic spec differ > on what constitutes engineering notation, there's a bug in the Python > decimal library, or you're hitting some obscure part of the spec's > definition. I don't have the e

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-22 Thread Xavier Ho
On Fri, Apr 23, 2010 at 12:23 AM, D'Arcy J.M. Cain wrote: > Now try returning the top two or four numbers. > >>> numbers = [1, 4, 5, 3, 7, 8] >>> sorted(numbers)[-2:] [7, 8] >>> sorted(numbers)[-4:] [4, 5, 7, 8] I see what you mean. This is not as intuitive, is it? Cheers, Xav -- http://mail

Re: Hi, friends. I wanna ask if there is a function which is able to take a list as argument and then return its top-k maximums?

2010-04-22 Thread Xavier Ho
On Fri, Apr 23, 2010 at 12:04 AM, Tim Golden wrote: > Assuming top-k doesn't mean something obscurely statistical: > > l = [1,2, 3, 4, 5] > k = 3 > print (sorted (l, reverse=True)[:k]) > You don't really need to reverse sort there: >>> numbers = [1, 4, 5, 3, 7, 8] >>> sorted(numbers)[3:] [5, 7,

Re: Re: Code redundancy

2010-04-20 Thread Xavier Ho
On Wed, Apr 21, 2010 at 7:59 AM, Alan Harris-Reid < aharrisr...@googlemail.com> wrote: > The code is not usually in class.__init__ (otherwise I would have used the > self. prefix) Alan, if your variables are not usually in __init__, what's preventing you from using class variables like this: >>

Re: problems creating and adding class instances to a list:

2010-04-19 Thread Xavier Ho
On Tue, Apr 20, 2010 at 7:38 AM, Chris Rebert wrote: > Additionally, `self.x = int` might not do what you thought it does. It > does *not* create a new instance variable of type 'int'. Instead, it > literally assigns to a new instance variable x the *function*† that > converts values into integer

Re: problems creating and adding class instances to a list:

2010-04-19 Thread Xavier Ho
On Tue, Apr 20, 2010 at 7:21 AM, Robert Somerville < rsomervi...@sjgeophysics.com> wrote: > class ctest(): > x = int > y = [1,2,3] > Variables defined directly under the class are known as "static variables" in many other languages. Here in Python it's called a class variable, but they're sti

Re: Default paranmeter for packed values

2010-04-18 Thread Xavier Ho
On Mon, Apr 19, 2010 at 9:46 AM, Chris Rebert wrote: > It doesn't really make sense to use * in such situations anyway, you > can just do the normal `z = (1,2,3)` But calling function(1.0, (0.0, 1.0, 0.0)) has been a big pet peeve of mine, and it looks extremely ugly and, imo, unpythonic. On M

Default paranmeter for packed values

2010-04-18 Thread Xavier Ho
uot;", line 1 def t(a, *b = (3, 4)): ^ SyntaxError: invalid syntax What was the rationale behind this design? Cheers, Ching-Yun Xavier Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com Website: http://xavierho.com/ -

Re: Calling a class method

2010-04-17 Thread Xavier Ho
On Sat, Apr 17, 2010 at 11:09 PM, vsoler wrote: > I have the following script: > > class TTT(object): >def duplica(self): >self.data *= 2 >def __init__(self, data): >self.data = data >TTT.duplica(self.data) > You're calling duplica with the class, and not by its o

  1   2   3   4   >