Re: Dual Core outlook

2006-02-07 Thread Xavier Morel
malv wrote: > Maybe this is too simplistic, but given two programs, one in Python the > other in Java or C#. Would this mean that running the latter on a dual > core processor would significantly increase execution speed, whereas > the Python program would be running in one processor only without a

Re: tricky regular expressions

2006-02-07 Thread Xavier Morel
Ernesto wrote: > I'm not sure if I should use RE's or some other mechanism. Thanks > I think a line-based state machine parser could be a better idea. Much simpler to build and debug if not faster to execute. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python good for web crawlers?

2006-02-07 Thread Xavier Morel
Paul Rubin wrote: > Generally I use urllib.read() to get > the whole html page as a string, then process it from there. I just > look for the substrings I'm interested in, making no attempt to > actually parse the html into a DOM or anything like that. > BeautifulSoup works *really* well when you

Re: tricky regular expressions

2006-02-07 Thread Xavier Morel
Ernesto wrote: > Xavier Morel wrote: >> Ernesto wrote: >>> I'm not sure if I should use RE's or some other mechanism. Thanks >>> >> I think a line-based state machine parser could be a better idea. Much >> simpler to build and debug if not f

Re: Hi reliability files, writing,reading and maintaining

2006-02-07 Thread Xavier Morel
Terry Reedy wrote: > "John Pote" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> I would wish to secure this data gathering against crashes of the OS, > > I have read about people running *nix servers a year or more without > stopping. > He'd probably want to check the various

Re: A __getattr__ for class methods?

2006-02-08 Thread Xavier Morel
Dylan Moreland wrote: > I'm trying to implement a bunch of class methods in an ORM object in > order to provide functionality similar to Rails' ActiveRecord. This > means that if I have an SQL table mapped to the class "Person" with > columns name, city, and email, I can have class methods such as:

Re: A __getattr__ for class methods?

2006-02-08 Thread Xavier Morel
Oh, and I wondered too: is your goal to build an ORM, or do you just need an ORM? Cause if it's the latter then Python does already have some fairly good ORMs such as SQLAlchemy or PyDO2, you don't *need* to create yours. -- http://mail.python.org/mailman/listinfo/python-list

Re: Ternary Operator Now?

2006-02-08 Thread Xavier Morel
Ben Wilson wrote: > I read somewhere else that Python was getting a ternary operator (e.g. > x = (true/false) ? y : z). I read the PEP about it and that the PEP had > been approved this past Fall. Has this been released into the wild yet? > > IIRC, the operator is like: > > x = y if C : else z >

Re: creat a DOM from an html document

2006-02-09 Thread Xavier Morel
Mark Harrison wrote: > I thought I saw a package that would create a DOM from html, with > allowances that it would do a "best effort" job to parse > non-perfectly formed html. > > Now I can't seem to find this... does anybody have a recommendation > as to a good package to look at? > > Many TIA!

Re: Create dict from two lists

2006-02-10 Thread Xavier Morel
Diez B. Roggisch wrote: > py wrote: > >> I have two lists which I want to use to create a dictionary. List x >> would be the keys, and list y is the values. >> >> x = [1,2,3,4,5] >> y = ['a','b','c','d','e'] >> >> Any suggestions? looking for an efficent simple way to do this...maybe >> i am jus

Re: appending to a list via properties

2006-02-11 Thread Xavier Morel
Alex Martelli wrote: > Carl Banks <[EMAIL PROTECTED]> wrote: >... >>> class better_list (list): >>> tail = property(None, list.append) >> This is an impressive, spiffy little class. > > Yes, nice use of property. > > Alex I don't know, I usually see people considering that proper

Re: Python, Forms, Databases

2006-02-15 Thread Xavier Morel
Tempo wrote: > Larry I do see your point. There does seem to be a lot more support for > PHP and MySQL together than there is Python and ASP. But I want to > first try to accomplish my goal by using Python first before I give up > and revert back to PHP. So if I was going to parse HTML forms and pl

Re: define loop statement?

2006-02-17 Thread Xavier Morel
Rene Pijlman wrote: > David Isaac: >> I would like to be able to define a loop statement >> (nevermind why) so that I can write something like >> >> loop 10: >>do_something >> >> instead of >> >> for i in range(10): >>do_something >> >> Possible? If so, how? > > Yes. By implementing a com

Re: define loop statement?

2006-02-17 Thread Xavier Morel
Rene Pijlman wrote: > David Isaac: >> I would like to be able to define a loop statement >> (nevermind why) so that I can write something like >> >> loop 10: >>do_something >> >> instead of >> >> for i in range(10): >>do_something >> >> Possible? If so, how? > > Yes. By implementing a com

Re: Processing text using python

2006-02-20 Thread Xavier Morel
nuttydevil wrote: > Hey everyone! I'm hoping someone will be able to help me, cause I > haven't had success searching on the web so far... I have large chunks > of text ( all in a long string) that are currently all in separate > notebook files. I want to use python to read these strings of text, >

Re: Processing text using python

2006-02-20 Thread Xavier Morel
Fredrik Lundh wrote: > did you read the string chapter in the tutorial ? > > http://docs.python.org/tut/node5.html#SECTION00512 > > around the middle of that chapter, there's a section on slicing: > > "substrings can be specified with the slice notation: two indices > sep

Re: Pure python implementation of string-like class

2006-02-25 Thread Xavier Morel
Akihiro KAYAMA wrote: > Sorry for my terrible English. I am living in Japan, and we have a > large number of characters called Kanji. UTF-16(U+...U+10) is > enough for practical use in this country also, but for academic > purpose, I need a large codespace over 20-bits. I wish I could use >

Re: Pure python implementation of string-like class

2006-02-25 Thread Xavier Morel
Ross Ridge wrote: > Steve Holden wrote: >> "Wider than UTF-16" doesn't make sense. > > It makes perfect sense. > > Ross > Ridge > Not if you're still within Unicode / Universal Character Set code space. While UCS-4 technically goes

Re: Pure python implementation of string-like class

2006-02-26 Thread Xavier Morel
Ross Ridge wrote: > Xavier Morel wrote: >> Not if you're still within Unicode / Universal Character Set code space. > > Akihiro Kayama in his original post made it clear that he wanted to use > a character set larger than entire Unicode code space. > >

Re: How to do an 'inner join' with dictionaries

2006-02-27 Thread Xavier Morel
[EMAIL PROTECTED] wrote: > Let's say I have two dictionaries: > dict1 is 1:23, 2:76, 4:56 > dict2 is 23:A, 76:B, 56:C > > How do I get a dictionary that is > 1:A, 2:B, 4:C > >>> dict1 = {1:23,2:76,4:56} >>> dict2 = {23:'A',76:'B',56:'C'} >>> dict((k, dict2[v]) for k, v in dict1.items()) {

Re: Why I chose Python over Ruby

2006-03-05 Thread Xavier Morel
I'll just play the devil's advocate here Francois wrote: > 1) In Ruby there is a risk of "Variable/Method Ambiguity" when calling > a method with no parameters without using () : > Yes, but that's in my opinion a programmer error, not necessarily a language error. > 2) Ruby does not have true f

Re: Why I chose Python over Ruby

2006-03-06 Thread Xavier Morel
Bil Kleb wrote: > Xavier Morel wrote: >>> 2) Ruby does not have true first-class functions living in the same >>> namespace as other variables while Python does : >>> >>> In Ruby you need extra syntax that ruins the "first-class-ness" : >>&

Re: Why I chose Python over Ruby

2006-03-06 Thread Xavier Morel
Torsten Bronger wrote: > Yes, however, this is also true for Python in my opinion. > Ruby's ability to generate DSLs is an order of magnitude better than Python's at least. I only know of the Lisp dialects that get better at DSLs. Check Rails' validation methods (in the models), or if you don't

Re: how do you move to a new line in your text editor?

2006-03-06 Thread Xavier Morel
John Salerno wrote: > So I'm wondering, how do you all handle moving around in your code in > cases like this? Is there some sort of consistency to these things that > you can write rules for your text editor to know when to outdent? It > doesn't seem like you can do this reliably, though. Under

Re: Use python from command line

2006-03-06 Thread Xavier Morel
trixie wrote: > Using WinXP and Python24 on generic desktop. > Being used to linux and command line operations I cannot make Windows accept > the 'python myprog.py' command. > Any help appreciated. > Bob > > I think you could've given us the error message that this command yields. Issue is pro

Tkinter custom drawing

2007-06-07 Thread Xavier Bérard
unity's posts). Anyone have a clue ? Thanks, Xavier Berard -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter custom drawing

2007-06-08 Thread Xavier Bérard
> from Tkinter import Invisiblecanvas ? The whole web never mentions this Invisiblecanvas. Do you have anything alike to share ? ;) Xavier -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter custom drawing

2007-06-08 Thread Xavier Bérard
> > > Now, the problem, is that I have already plenty of widgets on my > > screen. I just want to draw over them, which is a bit difficult in my > > comprehension of things. > > What are you trying to achieve by "drawing over" widgets? Want I want to do is a sort of GUI builder for Tkinter. I al

Re: Tkinter custom drawing

2007-06-09 Thread Xavier Bérard
Thank you this is nice code. I never thought of using the move_pending method.. Still it doesn't answer my question (which I ensure is very unclear). But do not worry, I found some way to get throught my dilemma and I can live easily with it. Thanks for your help. -- http://mail.python.org/mailm

Catching and automating a win32 MessageBox

2007-11-08 Thread Xavier Homs
Hi, I'm using an application that shows a standard (YES/NO) reconnect MessageBox each time if loses conection with its server. It defaults to YES. Is there any way to hook such a MessageBox a send a default action (yes) from a Python Script? All I've been able to do is to get a HWND with win32gu

problem in reading indices

2007-12-13 Thread Xavier Barthelemy
#x27;t understand why. What's wrong? May anyone have an idea? Xavier pm: and print type(ArrayWithData), ArrayWithData gives me [array([ 2.01, 5.01]),...] -- http://mail.python.org/mailman/listinfo/python-list

where can I find gdkimlib (imlib bindings)?

2008-04-24 Thread Xavier Toth
I'm trying to get some old code that imported GdkImlib to work but I can't find these a current version of these binding, anyone know where they are? -- http://mail.python.org/mailman/listinfo/python-list

Re: a question about zip...

2006-03-08 Thread Xavier Morel
KraftDiner wrote: > I had a structure that looked like this > ((0,1), (2, 3), (4, 5), (6,7) > > I changed my code slightly and now I do this: > odd = (1,3,5,7) > even = (0,2,4,6) > all = zip(even, odd) > > however the zip produces: > [(0, 1), (2, 3), (4, 5), (6, 7)] > > Which is a list of tuples

Re: python debugging question

2006-03-08 Thread Xavier Morel
[EMAIL PROTECTED] wrote: > I am a python newbie. I have writen some 500 lines of code. There are 4 > classes and in all 5 files. > > Now, I am trying to run the program. I am getting wrong values for the > simulation results. > Is there any debugging facilities in python which would let me go step

Re: Hashtables in pyhton ...

2006-03-09 Thread Xavier Morel
Konrad Mühler wrote: > Hi, > > are there predefinded chances to use hashtables in python? How can I use > Hashtable in python? Or do I have to implement this on my own? > > Thanks A Java Hashtable/Hashmap is equivalent to a Python dictionary, which is a builtin objects (and not a second-class c

Re: unsupported operand type(s) for %: 'NoneType' and 'tuple'

2009-12-07 Thread Xavier Ho
Hi Victor, the .append function doesn't return anything, so it's a None. And you should have it inside the parentheses. >>> tree.append("%s%s" % ("\t" * level, name)) is probably what you're after. Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: Overriding the >> builtin

2009-12-11 Thread Xavier Ho
On Fri, Dec 11, 2009 at 12:05 PM, Kevin Ar18 wrote: > I am aware of the fact that you can somehow replace the __builtins__ in > Python. There is a library here that modifies the >> binary builtins: > http://github.com/aht/stream.py/blob/master/stream.py > > Question: Is there anywhere that expl

Re: Class variables static by default?

2009-12-19 Thread Xavier Ho
Yes, if you want instance variables that are unique to each instance of a class, do the following: class Parser: def __init__(self): self.items = [] And that should work fine. J:\_Programming Projects\Python>python test.py <__main__.Parser object at 0x0240E7B0> <__main__.Parser object

Re: Invalid syntax error

2009-12-20 Thread Xavier Ho
Putting quotemarks "" around the path would be a good start, I think. Cheers, Xav On Sun, Dec 20, 2009 at 11:40 PM, Ray Holt wrote: > Why am I getting an invalid syntax error on the following: > os.chdir(c:\\Python_Modules). The error message says the colon after c is > invalid syntax. Why is

Re: a=[1,2,3,4].reverse() - why "a" is None?

2009-10-12 Thread Xavier Ho
Nadav, it's because reverse() modifies the list in-place. I've gotten this gotcha many times, If you had done: >>> a = [1,2,3,4] >>> a.reverse() >>> a [4, 3, 2, 1] Or even better: >>> a = [1,2,3,4][::-1] >>> a [4, 3, 2, 1] Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: The rap against "while True:" loops

2009-10-12 Thread Xavier Ho
On Mon, Oct 12, 2009 at 11:32 PM, Luis Zarrabeitia wrote: > Actually, in python, this works even better: > > for lin in iter(file_object.readline, ""): >... do something with lin > > What about >>> with open(path_string) as f: >>> for line in f: >>> # do something Cheers, X

Re: What command should be use when the testing of arguments is failed?

2009-10-14 Thread Xavier Ho
On Thu, Oct 15, 2009 at 10:58 AM, Peng Yu wrote: > I actually wanted to ask what return code should be returned in this > case when the arguments are not right. Thank you1 > > I think that depends on the design of the program. Is there a return value that would make sense to be returned by defaul

Re: () vs. [] operator

2009-10-15 Thread Xavier Ho
On Thu, Oct 15, 2009 at 5:14 PM, Ole Streicher wrote: > So what is the reason that Python has separate __call__()/() and > __getitem__()/[] interfaces and what is the rule to choose between them? Hi, This is very interesting, a thought that never occured to me before. Usually, a function is a

Re: () vs []

2009-10-15 Thread Xavier Ho
On Thu, Oct 15, 2009 at 3:21 AM, Nanjundi wrote: > 3 You can’t find elements in a tuple. Tuples have no index method. > I don't know what language you're using there, but my Python tuples have indexes. >>> a = (1, 2, 3) >>> a (1, 2, 3) >>> a[1] 2 -- http://mail.python.org/mailman/listinf

Re: () vs []

2009-10-15 Thread Xavier Ho
On Thu, Oct 15, 2009 at 6:39 PM, Chris Rebert wrote: > Nanjundi meant "index method" as in "a method .index()" (i.e. a method > named "index") which searches through the container for the given item > and returns the index of the first instance of said item, like > list.index() does. > > Interest

Re: () vs []

2009-10-15 Thread Xavier Ho
On Thu, Oct 15, 2009 at 6:55 PM, Tim Golden wrote: > It was added relatively recently, around Python 2.6 I think, > at least partly as an oh-ok-then reaction to everyone asking: > "how come lists have .index and .count and tuples don't?" > and neverending "tuples-are-immutable-lists-no-they-aren'

Re: Problem

2009-10-15 Thread Xavier Ho
On Fri, Oct 16, 2009 at 3:28 AM, Ander wrote: > I can't send emails out. Can u fix this problem please? > I don't know what I'm missing here, but you evidently sent out an email to the Python mailing list... Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: md5 strange error

2009-10-21 Thread Xavier Ho
On Wed, Oct 21, 2009 at 6:11 PM, [email protected] < [email protected]> wrote: > >>> pass = md5.new() > File "", line 1 >pass = md5.new() > ^ > SyntaxError: invalid syntax > pass is a keyword in Python, you can't use it as an identifier. Try password instead. Cheers, Xav --

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-30 Thread Xavier Ho
Alf, I kindly urge you to re-read bartc's comments. He does have a good point and you seem to be avoiding direct answers. On Fri, Oct 30, 2009 at 1:17 PM, Alf P. Steinbach wrote: > * bartc: > >> You say elsewhere that you're not specifically teaching Python, but the >> text is full of technical

Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-30 Thread Xavier Ho
On Fri, Oct 30, 2009 at 1:48 PM, Alf P. Steinbach wrote: > Does that mean that 'print' is still subject to change as of 3.1.1? Funny that. They removed reduce() when Python moved from 2.6.x to 3.0. They even removed __cmp__(). Makes me a sad panda. Is print() subject to change as of 3.1.1? I'd

Re: Help resolve a syntax error on 'as' keyword (python 2.5)

2009-11-03 Thread Xavier Ho
I don't have Python 25 on my computer, but since codepad.org is using Python 2.5.1, I did a quick test: # input try: raise Exception("Mrraa!") except Exception as msg: print msg # output t.py:3: Warning: 'as' will become a reserved keyword in Python 2.6 Line 3 except Exception as ms

Re: Program to compute and print 1000th prime number

2009-11-07 Thread Xavier Ho
s what efforts you've put into solving this problem. Perhaps if you post your code that doesn't quite work, we can make suggestions on how to improve/fix it. Other than that, it's generally considered bad karma to give any kind of code, and we need to know where you are. my 2c, Xavi

Re: Logic operators with "in" statement

2009-11-16 Thread Xavier Ho
On Tue, Nov 17, 2009 at 12:02 AM, Mr.SpOOn wrote: > Hi, > I'm trying to use logical operators (or, and) with the "in" statement, > but I'm having some problems to understand their behavior. > Hey Carlo, I think your issue here is mistaking 'in' as a statement. It's just another logic operator, m

Re: Logic operators with "in" statement

2009-11-16 Thread Xavier Ho
On Tue, Nov 17, 2009 at 12:08 AM, Mr.SpOOn wrote: > Sorry for replying to myself, but I think I understood why I was wrong. > > The correct statement should be something like this: > > In [13]: ('b3' and '5') in l or ('3' and 'b3') in l > Out[13]: True > > Carlo, I'm not sure what that achieves.

Re: Logic operators with "in" statement

2009-11-16 Thread Xavier Ho
On Tue, Nov 17, 2009 at 12:46 AM, Chris Rebert wrote: > On Mon, Nov 16, 2009 at 6:23 AM, Xavier Ho wrote: > > AND operator has a higher precedence, so you don't need any brackets > here, I > > think. But anyway, you have to use it like that. So that's something &g

Re: What is the difference between 'except IOError as e:' and 'except IOError, e:'

2009-11-17 Thread Xavier Ho
On Wed, Nov 18, 2009 at 12:28 PM, Peng Yu wrote: > I don't see any different between the following code in terms of > output. Are they exactly the same ('as' v.s. ',')? > Yes, they're exactly the same. However, the syntax with "as" is newer, introducted in Python 3.x, and eventually backported t

Re: Securing a multiprocessing.BaseManager connection via SSL

2009-11-24 Thread Xavier Sanz
Hi Jonas I've having same need so i found a solution but you need to hack a bit I am using python 2.6.3 but i suppose it could be applicable to your case. First of all u need to edit /usr/lib/python2.6/lib/python2.6/ multiprocessing/connection.py This is mine: # # A higher level module for usi

Re: Securing a multiprocessing.BaseManager connection via SSL

2009-11-24 Thread Xavier Sanz
I recommend u to test it before use it in production environment. On 24 nov, 22:45, Xavier Sanz wrote: > Hi Jonas > > I've having same need so i found a solution but you need to hack a bit > > I am using python 2.6.3 but i suppose it could be applicable to your > case. >

Re: How to get UTC offset for non-standard time zone names?

2010-01-31 Thread Xavier Ho
This may not answer your question directly, but have you thought about ingoring the number at the end of these non-standard timezones? CDT is Central Daylight-saving Timezone, while CST is Central Standard Timezone. And you are correct they are -5 and -6 hours respectively. Does pytz know about CDT

Re: How to get UTC offset for non-standard time zone names?

2010-01-31 Thread Xavier Ho
Would it hurt if you put in some extra information? http://www.timeanddate.com/library/abbreviations/timezones/ HTH, -Xav P.S: You, sir, have an awesome first name. On Mon, Feb 1, 2010 at 1:57 AM, Skip Montanaro wrote: > > Does pytz know about CDT and CST? > > Nope... > > Skip > > > -- > htt

Re: Common area of circles

2010-02-04 Thread Xavier Ho
I'm not sure what you're after. Are you after how to calculate the area? Or are you trying to graph it? Or an analytical solution? What do you mean by "take out the intersection"? -Xav On Thu, Feb 4, 2010 at 9:47 PM, Shashwat Anand wrote: > I wanted some general suggestion/tips only > > > On Th

Re: Common area of circles

2010-02-04 Thread Xavier Ho
It's an interesting problem. Never thought it was this difficult. I can't account for all geometrical enumerations, but assuming all 4 circles intersect, here's the solution for this particular senario. It's probably not going to be useful to you since you're working on geometrical approximations n

Re: Your beloved python features

2010-02-04 Thread Xavier Ho
Personally, I love the fact that I can type in 2**25 in the intepreter without crashing my machine. ;) Cheers, -Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with lambda

2010-02-18 Thread Xavier Ho
I'm looking at your code and was thinking ... why writing code that is difficult to understand? To answer your question though, they're different because in case "f", your lambda experssion is only evaluated once. That means the variable 'n' is ever only created once, and replaced repeatedly. In t

Re: How to make an empty generator?

2010-02-18 Thread Xavier Ho
I don't think it's a stupid question at all. =]. But wouldn't it solve the problem if you call the generator the first time you need it to yield? Cheers, Xav On Fri, Feb 19, 2010 at 9:30 AM, Robert Kern wrote: > On Feb 18, 5:08 pm, Steven D'Aprano > wrote: > > On 2010-02-18 16:25 PM, Stephen

Curiosity stirkes me on 'import this'.

2010-03-07 Thread Xavier Ho
Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn. Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr! And some other attributes in 'this' module as well, that decodes the string. I'm curious. Was this encoded purely for fun? *grins* Cheers, C

Re: GC is very expensive: am I doing something wrong?

2010-03-18 Thread Xavier Ho
Weeble, Try to use the full arguments of insert(i, x), instead of using list slices. Every time you create a slice, Python copies the list into a new memory location with the sliced copy. That's probably a big performance impact there if done recursively. My 2cp, Xav On Fri, Mar 19, 2010 at 10:

Re: "Usability, the Soul of Python"

2010-03-30 Thread Xavier Ho
Did no one notice that for(i = 99; i > 0; ++i) Gives you an infinite loop (sort of) because i starts a 99, and increases every loop? Cheers, Ching-Yun Xavier Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: [email protected] Website: h

Re: String Formatting Operations for decimals.

2010-04-01 Thread Xavier Ho
Hi Maxim, If it's the trailing zeroes you're concerned about, here's a work-around: >>> ('%.2f' % 10.5678).rstrip('0') '10.57 I'm sure there are better solutions. But this one works for your need, right? Cheers,' Ching-Yun Xavier Ho,

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 -- http:/

Re: PyGame migrating to JavaScript

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

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 inst

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

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 wrote: > 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) Provide a link to a P

Re: Splitting a string

2010-04-02 Thread Xavier Ho
output[-1]) ... 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,

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 < [email protected]> wrote: > Hi list, > > > > could someone recommend a good python ogl package (open source is > preferred) ? I found these ones so far: > > > > http://pyopengl

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

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: sum for sequences?

2010-04-06 Thread Xavier Ho
On Tue, Apr 6, 2010 at 11:39 PM, Albert van der Horst < [email protected]> 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 -- http://mail.python.org/mailman/listinfo

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 < [email protected]> 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: 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 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 context? Cheers, Xav --

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 wrote: > Hi

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

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: [email protected] Website: http://xavierho.com/ -

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

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 < [email protected]> 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: 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: Re: Code redundancy

2010-04-20 Thread Xavier Ho
On Wed, Apr 21, 2010 at 7:59 AM, Alan Harris-Reid < [email protected]> 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: 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: 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: 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: 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: 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: 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: 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: [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

<    1   2   3   4   >