Re: [OT] Awesome bug of the week

2014-08-13 Thread Xavier Ho
Haha! On 14 August 2014 14:54, Steven D'Aprano st...@pearwood.info 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 --

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

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, rahulredd...@hotmail.com wrote: So i have a set of for loops that create this : *** *** *** *** *** *** *** *** *** ***

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 sambez...@hotmail.co.uk wrote: Hi Xav, Iv been looking into OpenCV, i can easily stream my laptops webcam using this code. import cv2

Fwd: Recording live video stream from IP camera issue

2013-02-06 Thread Xavier Ho
On 6 February 2013 23:12, Sam Berry sambez...@hotmail.co.uk 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

Re: Recording live video stream from IP camera issue

2013-02-06 Thread Xavier Ho
On 7 February 2013 00:12, Sam Berry sambez...@hotmail.co.uk 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

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 module test() File test.py, line 295, in test assert not worker.is_alive() AssertionError The

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 michelle.cou...@txdot.govwrote: Does anyone know of a website or forum where there is help for ArcPY (Python) programmers? ESRI’s (GIS) resource

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 deute...@xrs.net 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

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): File stdin, line

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 ros...@gmail.com wrote: On Tue, Jan 17, 2012 at 5:47 PM, Xavier Ho cont...@xavierho.com wrote: What was the rationale behind this design? Specifically, (None 0) == True and (None == 0

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,

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 pyt...@rcn.com 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(

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 azeyn...@gmail.com wrote: Hello, I am working with Google App Engine python version. The app sends an email to the user

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:

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 li...@asd-group.com 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

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

2010-10-29 Thread Xavier Ho
On 29 October 2010 15:50, Paul Rubin no.em...@nospam.invalid wrote: John Nagle na...@animats.com 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

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 elkar...@gmail.com wrote: On Oct 28, 6:16 pm, cbr...@cbrownsystems.com cbr...@cbrownsystems.com wrote: It's clear but tedious to write:

Re: How on Factorial

2010-10-28 Thread Xavier Ho
On 27 October 2010 18:27, Arnaud Delobelle arno...@gmail.com 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

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

2010-10-28 Thread Xavier Ho
On 28 October 2010 20:24, Alex sigma.z.1...@gmail.com 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(Button-1,self.pop2pop) what am I doing wrong? Try

Re: How on Factorial

2010-10-28 Thread Xavier Ho
On 28 October 2010 23:52, Dave Angel da...@ieee.org 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

Re: How on Factorial

2010-10-28 Thread Xavier Ho
On 29 October 2010 00:13, Dave Angel da...@ieee.org 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

Re: factorial of negative one (-1)

2010-10-28 Thread Xavier Ho
On 29 October 2010 14:41, Bj Raz whitequill...@gmail.com 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

Re: programming

2010-09-20 Thread Xavier Ho
On 20 September 2010 15:46, Jordan Blanton jeblan...@crimson.ua.edu 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

Re: programming

2010-09-20 Thread Xavier Ho
On 20 September 2010 16:25, Jordan Blanton jeblan...@crimson.ua.edu 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

Re: programming

2010-09-20 Thread Xavier Ho
On 20 September 2010 16:38, Jordan Blanton jeblan...@crimson.ua.edu 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

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 jeblan...@crimson.ua.edu 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

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

Re: programming

2010-09-20 Thread Xavier Ho
On 20 September 2010 17:29, Xavier Ho cont...@xavierho.com 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 fails. Cheers

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 kwatford+pyt...@gmail.comkwatford%2bpyt...@gmail.com 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

Re: Very stupid question about a % symbol

2010-09-17 Thread Xavier Ho
On 17 September 2010 12:48, Terry Reedy tjre...@udel.edu 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.

Re: Very stupid question about a % symbol

2010-09-16 Thread Xavier Ho
On 17 September 2010 01:25, J dreadpiratej...@gmail.com 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 ben+pyt...@benfinney.id.auben%2bpyt...@benfinney.id.au wrote: Paul Watson paul.hermeneu...@gmail.com writes: What is the currently favored installation process for Python applications? ‘python ./setup.py install’, using the standard library's

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

2010-09-07 Thread Xavier Ho
On 7 September 2010 10:56, MRAB pyt...@mrabarnett.plus.com 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: mutate dictionary or list

2010-09-07 Thread Xavier Ho
On 7 September 2010 22:05, Baba raoul...@gmail.com 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.

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

2010-09-06 Thread Xavier Ho
On 7 September 2010 10:37, ceycey cuneyt.er...@gmail.com 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

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Xavier Ho
On 2 September 2010 00:47, Alban Nona python.k...@gmail.com 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,

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Xavier Ho
On 2 September 2010 01:11, Alban Nona python.k...@gmail.com 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,

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Xavier Ho
On 2 September 2010 02:49, Alban Nona python.k...@gmail.com 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',

Re: Dumb Stupid Question About List and String

2010-09-01 Thread Xavier Ho
2010/9/2 Alban Nona python.k...@gmail.com 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-08-31 Thread Xavier Ho
On 1 September 2010 07:57, Alban Nona python.k...@gmail.com 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. (On topic:

Re: Dumb Stupid Question About List and String

2010-08-31 Thread Xavier Ho
On 1 September 2010 12:00, Alban Nona python.k...@gmail.com 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: 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 et...@stoneleaf.us 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

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 cont...@xavierho.com wrote: Ethan, are you trying to write the constructor in the class statement? Cheers, Xav On 31 August 2010 00:10, Ethan

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 nswebs...@gmail.com 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

Re: pythonize this!

2010-06-15 Thread Xavier Ho
On 15 June 2010 21:49, superpollo ute...@esempio.net 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] *

Re: pythonize this!

2010-06-15 Thread Xavier Ho
On 15 June 2010 22:55, superpollo ute...@esempio.net 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

Re: a +b ?

2010-06-11 Thread Xavier Ho
2010/6/12 yanhua gasf...@163.com 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

Re: What does this PyChecker warning mean?

2010-06-01 Thread Xavier Ho
On 1 June 2010 21:48, Leo Breebaart l...@lspace.org 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: reading help() - newbie question

2010-05-31 Thread Xavier Ho
On 31 May 2010 20:19, Payal payal-pyt...@scriptkitchen.com 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

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), (0, 0, 1),

Re: A Friday Python Programming Pearl: random sampling

2010-05-29 Thread Xavier Ho
On 29 May 2010 06:44, Mark Dickinson dicki...@gmail.com 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

Re: Creating a single list

2010-05-29 Thread Xavier Ho
On 29 May 2010 23:24, Astley Le Jasper astley.lejas...@gmail.com wrote: def createlist(): column_title_list = ( (id,20,integer), (companyname,50,text), getproducts(),

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: if, continuation and indentation

2010-05-27 Thread Xavier Ho
On 27 May 2010 22:22, HH henri...@gmail.com 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

Re: if, continuation and indentation

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

Re: if, continuation and indentation

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

Re: if, continuation and indentation

2010-05-27 Thread Xavier Ho
On 27 May 2010 23:26, Xavier Ho cont...@xavierho.com 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: 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 stu...@molden.no 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

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 doctore...@gmail.com 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 --

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. self._x =

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 pmau...@gmail.com wrote: On May 14, 3:19 am, harry k hkiri...@yahoo.com.au wrote: Write a spell checking tool that wil... Well,

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 hkiri...@yahoo.com.au wrote: Write a spell checking tool that will identify all misspelled word in a text file using a provided

Re: Human word reader

2010-05-15 Thread Xavier Ho
On Sat, May 15, 2010 at 9:02 PM, timo verbeek timoverbee...@gmail.comwrote: I'm planning to create a human word program snip 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

Re: Human word reader

2010-05-15 Thread Xavier Ho
On Sat, May 15, 2010 at 9:12 PM, Xavier Ho cont...@xavierho.com 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 for late night e

Re: Human word reader

2010-05-15 Thread Xavier Ho
On Sat, May 15, 2010 at 9:32 PM, timo verbeek timoverbee...@gmail.comwrote: On May 15, 1:02 pm, timo verbeek timoverbee...@gmail.com 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

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 nill...@yahoo.com wrote: Hello I am trying

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 dasarathulag...@gmail.comwrote: 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 --

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 dasarathulag...@gmail.comwrote: 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,

Re: solve a newspaper quiz

2010-05-09 Thread Xavier Ho
On Sun, May 9, 2010 at 7:20 PM, superpollo ute...@esempio.net 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: 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 mannu_0...@rediffmail.com wrote: Hi, I have few files like this: 24

Re: [Python-ideas] division oddness

2010-05-06 Thread Xavier Ho
On Fri, May 7, 2010 at 11:13 AM, Chris Rebert pyid...@rebertia.com wrote: On Thu, May 6, 2010 at 5:43 PM, Mathias Panzenböck grosser.meister.mo...@gmx.net 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

Re: [Python-ideas] division oddness

2010-05-06 Thread Xavier Ho
On Fri, May 7, 2010 at 12:14 PM, Chris Rebert c...@rebertia.com 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

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 richard.lam...@bilcom.atwrote: 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.

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:19 PM, Chris Rebert c...@rebertia.com 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

Re: Engineering numerical format PEP discussion

2010-04-25 Thread Xavier Ho
On Mon, Apr 26, 2010 at 3:39 PM, Chris Rebert c...@rebertia.com 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

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 m...@timgolden.me.uk 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]

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 da...@druid.net 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 --

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: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 still the

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 c...@rebertia.com 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

Default paranmeter for packed values

2010-04-18 Thread Xavier Ho
)): ^ 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/ -- http://mail.python.org/mailman/listinfo/python

Re: Default paranmeter for packed values

2010-04-18 Thread Xavier Ho
On Mon, Apr 19, 2010 at 9:46 AM, Chris Rebert c...@rebertia.com 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,

Re: Calling a class method

2010-04-17 Thread Xavier Ho
On Sat, Apr 17, 2010 at 11:09 PM, vsoler vicente.so...@gmail.com 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,

Re: curious about python version numbers

2010-04-13 Thread Xavier Ho
Hi Alex, It's because Python 3.x introduced a lot of backwards incompatibilities. Python 2.7 aims to bridge that gap, so many 3rd party libraries that depend on Python 2.x can transit onto Python 3.x better, as I understand. Cheers, Xav On Mon, Apr 12, 2010 at 12:52 PM, Alex Hall

Re: Python does not allow a variable named pass

2010-04-11 Thread Xavier Ho
On Sun, Apr 11, 2010 at 11:40 PM, BJ Swope bigbluesw...@gmail.com wrote: Other than asking the website owner to change the name of the field how can I go about passing that field in the form post? How about: urllib.urlencode({'pass' : 'foo'}) And so on? What is your problem in this

Re: sum for sequences?

2010-04-06 Thread Xavier Ho
On Tue, Apr 6, 2010 at 11:39 PM, Albert van der Horst alb...@spenarnc.xs4all.nl wrote: Now for floating point numbers the order of summation is crucial, not commutative (a+b)+c a+(b+c). Could you shed some light on why is this? Cheers, Xav --

Re: pass object or use self.object?

2010-04-06 Thread Xavier Ho
So my question is whether it's bad practice to set things up so each method operates on self.document or should I pass document around from one function to the next? I think this depends on the use case. If the functions you're calling in between have a chance to be called independently,

Re: pass object or use self.object?

2010-04-06 Thread Xavier Ho
On Wed, Apr 7, 2010 at 1:19 AM, Jean-Michel Pichavant jeanmic...@sequans.com wrote: Usually, when using classes as namespace, functions are declared as static (or as classmethod if required). e.g. class Foo: @classmethod def process(cls, document): print 'process of'

Re: pythonrag

2010-04-05 Thread Xavier Ho
Python caches objects for reuse, but I'm not too certain on how it works, either. Seems a bit odd. I just tested on 2.6.5 and got the same result. This hasn't been a problem for me, though. Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: PyGame migrating to JavaScript

2010-04-02 Thread Xavier Ho
Javascript in recent years has been getting better and better, and now is a way better language than python. So to keep up with the times pygame has been rewritten for javascript. *shudders* Can someone convince me why that is a good idea at all? Any rationales? Cheers, -Xav --

Re: PyGame migrating to JavaScript

2010-04-02 Thread Xavier Ho
On Fri, Apr 2, 2010 at 6:19 PM, Gary Herron gher...@digipen.edu wrote: It's a joke -- see http://en.wikipedia.org/wiki/April_Fools%27_Dahttp://en.wikipedia.org/wiki/April_Fools%27_Day D'oh! Can't believe that got me. (It's already 2nd of April... you're not supposed to make that joke now!

Re: pynotify for python 3.1.. Help Please..

2010-04-02 Thread Xavier Ho
Hi Jebamnana, You'll probably have to copy the pynotify contents to the Python 3.1 folder. (under Libs\site-packages). You should be able to find the folder in the Python 2.6 paths. Once you do that, you can try to use it. But I don't know if pynotify will be able to run with Python 3.1. For

Re: pynotify for python 3.1.. Help Please..

2010-04-02 Thread Xavier Ho
On Fri, Apr 2, 2010 at 8:13 PM, Xavier Ho cont...@xavierho.com wrote: Hi Jebamnana, Jebagnana* Sorry. -Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: Splitting a string

2010-04-02 Thread Xavier Ho
Best I can come up with: def split_number(string): ... output = [string[0]] ... for character in string[1:]: ... if character.isdigit() != output[-1].isdigit(): ... output.append('') ... output[-1] += character ... return tuple(output) ...

Re: Hey Sci.Math, Musatov here. I know I've posted a lot of weird stuff trying to figure things out, but I really think I am onto something here and need some bright minds to have a look at this, co

2010-04-02 Thread Xavier Ho
On Fri, Apr 2, 2010 at 8:14 PM, A Serious Moment marty.musa...@gmail.comwrote: SPARSE COMPLETE SETS FOR NP: SOLUTION OF A CONJECTURE BY MARTIN MICHAEL MUSATOV * for llP: Sparse Comp1ete Sets Solution of a Conjecture Hi, If you're serious about this posting, could you please: 1)

Re: Splitting a string

2010-04-02 Thread Xavier Ho
]) ... output.append('') ... output[-1] += character ... return tuple(output) ... split_number('si_pos_99_rep_1_0.ita') ('si_pos_', 99, '_rep_', 1, '_', 0, '.ita') Cheers, Xav On Fri, Apr 2, 2010 at 8:26 PM, Xavier Ho cont...@xavierho.com wrote: Best I can come up with: def split_number(string

  1   2   3   >