Re: how to put form and display its result(data from database) on the same window?

2005-12-07 Thread Xavier Morel
[EMAIL PROTECTED] wrote: > Hi Guys, > > I have designed a web application. In its one window I put a form. User > can click submit button of this form to run a pathon script to get data > from database. Then User get a new window which display the result. Now > I want to put the form and display d

Re: How to find the type ...

2005-12-09 Thread Xavier Morel
Lad wrote: > Hello > How can I find out in Python whether the operand is integer or a > character and change from char to int ? > Regards, > L. > You may want to try the "type" command. And there is no character type in cPython (unless you're using ctypes that is) There is not much point though

Re: How to detect the presence of a html file

2005-12-09 Thread Xavier Morel
Phoe6 wrote: > Operating System: Windows > Python version: 2.4 > > I have bookmarks.html and wumpus.c under my c: > > When I tried to check the presence of the bookmarks.html, I fail. > os.path.isfile('c:\bookmarks.html') > False os.path.isfile('c:\wumpus.c') > True > os.path.exi

Re: Proposal: Inline Import

2005-12-09 Thread Xavier Morel
Shane Hathaway wrote: > Thoughts? >>> import re; name_expr = re.compile('[a-zA-Z]+') >>> name_expr <_sre.SRE_Pattern object at 0x00F9D338> >>> the import statement can be called anywhere in the code, why would you add strange syntactic sugar that doesn't actually bring anything? -- http://ma

Re: Another newbie question

2005-12-10 Thread Xavier Morel
Mike Meyer wrote: > And you've once again missed the point. The reason you don't > manipulate the attributes directly is because it violates > encapsulation, and tightens the coupling between your class and the > classes it uses. It means you see the implementation details of the > classes you are

Re: double underscore attributes?

2005-12-10 Thread Xavier Morel
[EMAIL PROTECTED] wrote: > Could someone explain the use of __add__ (and similar double underscore > attributes) and what their use is. > > Bob > Methods with double leading and trailing underscores are basically "magic methods" with specific meanings for the Python interpreter. You're not supp

Re: Great books on Python?

2005-12-11 Thread Xavier Morel
Tolga wrote: > I am not unfamiliar to programming but a newbie in Python. Could you > recommend me (a) great book(s) to start with? Free online books or > solid books are welcome. > > Thanx in advance. > I'd call Dive Into Python a reference, it's an extremely clear yet pythonic book, and it's a

Re: OO in Python? ^^

2005-12-11 Thread Xavier Morel
Matthias Kaeppler wrote: > Why would I want to use an attribute in Python, where I would use > getters and setters in Java? I know that encapsulation is actually just > a hack in Python (common, "hiding" an implementation detail by prefixing > it with the classname so you can't access it by its

Re: Displaying error message in a try except?

2005-12-11 Thread Xavier Morel
Fredrik Lundh wrote: > assuming that "true" means "the message you would get if you hadn't > used a try/except", the traceback module is what you want: > > you can also inspect the exception status via the sys.exc_info() call. > e.g. > There is also the third way of catching an exception exp

Re: Python is incredible!

2005-12-12 Thread Xavier Morel
Luis M. Gonzalez wrote: > You are not the first lisper who fell inlove with Python... > Check this out: > http://www.paulgraham.com/articles.html > Paul Graham is not in love with Python though, he's still very much in love with Lisp. He merely admits being unfaithful to Lisp from time to time (

Re: IsString

2005-12-13 Thread Xavier Morel
Tom Anderson wrote: > In what sense are the names-bound-to-references-to-objects not variables? > In the sense that a variable has various meta-informations (at least a type) while a Python name has no information. A Python name would be equivalent to a C void pointer, it can mean *any*thing an

Re: "0 in [True,False]" returns True

2005-12-13 Thread Xavier Morel
Mike Meyer wrote: > But this isn't necessarilly true: is perfectly legal. > > http://mail.python.org/mailman/listinfo/python-list

Re: Horribly noobful string question

2005-12-13 Thread Xavier Morel
Fredrik Lundh wrote: > "SeNTry" wrote: > >> My first post here as I just begin to learn programming in general and >> python in particular. I have all the noobie confused questions, but as I >> work thru the tutorials I'm sure I'll find most my answers. >> >> This one is eluding me tho... I am wo

Re: how can i change the default python?

2005-12-13 Thread Xavier Morel
Koray Bostancı wrote: > Hi all, > > When i type python in terminal it runs the python2.3 interpreter, but i > want to use 2.4 and Python2.4 package is already installed. > > How can i change the default python in my system? I searched google for > a little but couldn't find. > > Using Debian GNU

Re: IsString

2005-12-13 Thread Xavier Morel
Steven D'Aprano wrote: > name = "spam spam spam spam" > > the value of the variable "name" is a pointer, and not a string. Riiight. > Yes, it's a reference to an object of type string holding the value > def increment(n): > """Add one to the argument changing it in place.""" > # In Pas

Re: How can I load python script into Html ??

2005-12-13 Thread Xavier Morel
Shouldn't have hit the "send" button so fast... Addendum: the script element doesn't have any language attribute, the attribute you're supposed to use is "type" and it takes the MIME type of your script as a value. s/language="javascript"/type="text/javascript"/ -- http://mail.python.org/mailm

Re: How can I load python script into Html ??

2005-12-13 Thread Xavier Morel
PatPoul wrote: > I want to do the same thing as > > > but with a python script : > > > == > if xxx.py : > def mytest(): > alert("test") > window.document.write('test') > == > and test.html : > > > > > mytest() > >

Re: Why and how "there is only one way to do something"?

2005-12-15 Thread Xavier Morel
Aahz wrote: > In article <[EMAIL PROTECTED]>, > Steve Holden <[EMAIL PROTECTED]> wrote: >> (Part of) Python's credo (which you can read in context by typing >> >> import this >> >> at an interactive command prompt) is "There should be one (and >> preferably only one) way to do it". > > Actua

Re: Tuples

2005-12-15 Thread Xavier Morel
Tuvas wrote: > Let's say I make a program something like follows: > > x=[] > x.append([1,2,3]) > x.append([4,5,6]) > print x > print x[0] > print x[0][1] > x[0][1]=5 > > Okay, everything works here as expected except the last line. Why won't > this work? Thanks for the help! > Works for me, do y

Re: RoR like (was : SPE 0.8.1.b Python IDE...)

2005-12-15 Thread Xavier Morel
Adrian Holovaty wrote: > bruno at modulix wrote: >> RoR is not an IDE, it's a web framework. The closest things in Python >> are TurboGears (good Ajax/js support via Mochikit), Subway (never >> tested), and Django (no Ajax support AFAIK). > > Note that "no Ajax support" is misleading. Of course yo

Re: urllib.urlopen

2005-12-17 Thread Xavier Morel
JabaPyth wrote: > Hello, > I'm trying to use the urllib module, but when i try urllib.urlopen, it > gives me a socket error: > > >>import urllib > >>print urllib.urlopen('http://www.google.com/').read() > Traceback (most recent call last): > File "", line 1, in ? > File "C:

Re: Can you pass functions as arguments?

2005-12-19 Thread Xavier Morel
[EMAIL PROTECTED] wrote: > I want to calculate f(0) + f(1) + ...+ f(100) over some function f > which I can change. So I would like to create a function taking f as > argument giving back the sum. How do you do that in Python? > Python functions (and classes, and modules) are first-class objects,

Re: When Python *Eggs* better than Python *distutils*?? What's Eggs?

2005-12-20 Thread Xavier Morel
[EMAIL PROTECTED] wrote: > So basically Python Eggs precompiles and compresses > binaries for you so you just have to load it to run > your app? > Nah, Eggs is a packaging system, what you don't have to do is compile/configure, because the packaging does that for you. It also handles things lik

Re: Try Python update

2006-01-06 Thread Xavier Morel
Mike Meyer wrote: > After spending time I should have been sleeping working on it, the try > python site is much more functional. It now allows statements, > including multi-line statements and expressions. You can't create code > objects yet, so it's still more a programmable calculator than > any

Re: [OT] - Requesting Comments for Process Definition and Presentation

2006-01-06 Thread Xavier Morel
Ilias Lazaridis wrote: > b) to retrieve feedback subjecting the Process Definition itself > (content of diagramms, clarity, terminology etc.) > This is a lie, and you know it. You are merely some kind of strange troll. You've built something that you consider the only "object model" worth using

Re: Python or Java or maybe PHP?

2006-01-06 Thread Xavier Morel
Mike Meyer wrote: > That doesn't sounds like "hates" to me. More like "doesn't like the > baggage." > > >> # Current behavior >>> def foo(*args, **kwargs): pass >>> print foo >>> # Extended behavior >>> # returns a reference to the function >>> def foo(*args, **kwarg

Re: One-step multiples list generation?

2006-01-06 Thread Xavier Morel
Damien Wyart wrote: > Thanks for these important and useful additions, they are very welcome ! > > In writing my answer I had immutables in mind, but mutables are a bit > more dangerous, here... > Not *that* much though. The first construct can't be used, but he can use >>> [copy.copy(Foo) fo

Re: Translate this to python?

2006-01-06 Thread Xavier Morel
[EMAIL PROTECTED] wrote: > For some reason, ocassionally when I see xrange, I think "But wasn't > that deprecated since range is now a . . oh wait that's xreadlines". > xrange is a cool thing the few times where you really need it. > > john > >> Not sure what i is really for, but j seems to be

Re: Inheritance problem?

2006-01-06 Thread Xavier Morel
Pierre Barbier de Reuille wrote: > Well, I would even add : don't use super ! > Just call the superclass method : > > MyClass.__init__(self) > > > > Simon Percivall a écrit : >> Don't use self.__class__, use the name of the class. >> Bad idea if you're using new-style classes with a complex inh

Re: inline function call

2006-01-06 Thread Xavier Morel
Peter Hansen wrote: > Riko, any chance you could post the final code and a bit more detail on > exactly how much Psyco contributed to the speedup? The former would be > educational for all of us, while I'm personally very curious about the > latter because my limited attempts to use Psyco in th

Re: - E04 - Leadership! Google, Guido van Rossum, PSF

2006-01-06 Thread Xavier Morel
Ilias Lazaridis wrote: > I estimate that there is a "unfreeze" operation, too - which would lead > to flexibity. > There is none, you have to make a copy of the object via the "dup" (duplicate) method to get an unfrozen copy (note: clone yields an exact copy, which means that it's still frozen)

Re: Spelling mistakes!

2006-01-06 Thread Xavier Morel
KraftDiner wrote: > I've spent hours trying to find a bug that was a simple spelling > mistake. > > in an init method I declare a variable self.someLongName > > later in a different method of the class I use > self.sumLongName > Now I really meant self.someLongName. > In fact I don't want a vari

Re: Translate this to python?

2006-01-06 Thread Xavier Morel
Heiko Wundram wrote: > Xavier Morel wrote: >> I think that xrange is also soon-to-be deprecated (xrange eats a little >> less memory and is slightly faster to _create_, but much slower to >> _iterate over_ than range) > > It might be slower to iterate using xrange, b

Re: Python or Java or maybe PHP?

2006-01-06 Thread Xavier Morel
Alex Martelli wrote: > Xavier Morel <[EMAIL PROTECTED]> wrote: >... >> Wouldn't it be possible to change the `def` statement to return a >> reference to the function, and allow omitting the function name thereby >> bypassing the default binding (curr

Re: Inheritance problem?

2006-01-06 Thread Xavier Morel
Pierre Barbier de Reuille wrote: > Xavier Morel a écrit : >> Pierre Barbier de Reuille wrote: >> >>> Well, I would even add : don't use super ! >>> Just call the superclass method : >>> >>> MyClass.__init__(self) >>> >>> &g

Re: python speed

2006-01-07 Thread Xavier Morel
James Tanis wrote: > Quite honestly I've never heard of java being faster than.. well.. > anything. Faster than Python? I really doubt it. Their are several > libraries for game programming specifically as well as opengl, sdl, as > well as several different audio systems/daemons.. I'd suggest brow

Stackless Python

2006-01-07 Thread Xavier Morel
Some time ago, I finally decided to check what Stackless was (exactly) and which were the theorical concepts behind it (continuations and all). I managed to find some documentations and papers, but most if not all of them are related to pre-2.0 Stackless. The issue is, I just can't seem to reac

Re: Stackless Python

2006-01-07 Thread Xavier Morel
Christian Tismer wrote: > Xavier Morel wrote: > >> Would anyone have more informations about that? It doesn't seem to be an >> issue on my side (since I tried to access the Stackless site from two >> different connections and 3 computers) but I can't rule it

Re: Spelling mistakes!

2006-01-09 Thread Xavier Morel
Antoon Pardon wrote: > I don't think unit tests are that helpful in this case. > Unit tests help you in finding out there is a bug, they > don't help that much in tracking down a bug. > > I for some reason a person is reading over the difference > between sumLongName and someLongName and doesn't n

Re: Problema con le RE....

2006-01-09 Thread Xavier Morel
Alessandro wrote: > Problema con le RE > Ho questa stringa "3 HOURS, 22 MINUTES, and 28 SECONDS" e la devo > 'dividere' nelle sue tre parti "3 HOURS", "22 MINUTES", "28 SECONDS". > La cosa mi viene molto con le RE...(inutile la premessa che sono molto > alle prime armi con RE e Python) > Qesi

Re: how to improve this simple block of code

2006-01-11 Thread Xavier Morel
Mel Wilson wrote: > py wrote: >> Say I have... >> x = "132.00" >> >> but I'd like to display it to be "132" ...dropping the trailing >> zeros... > > print '%g' % (float(x),) > > might work. > > Mel. > The input is a string, %g expects a float, TypeError exception. -- http://mail.python.o

Re: how to improve this simple block of code

2006-01-11 Thread Xavier Morel
Forget about the previous mail, i just saw you were converting the string to float beforehand, in which case he would more than likely run into the good ol' float imprecision issue sooner than later. Not to mention that %g formats to scientific notation (e.g. exponential format with the exponen

Re: Freezing

2006-01-12 Thread Xavier Morel
[EMAIL PROTECTED] wrote: > The first line of that example has to be: > > s = |set([1, 3, 5])| > > But I don't know/remember why set() can't accept many values like > max/min: > > max([1,2,5]) > max((1,2,5)) > max(1,2,3) > > Bye, > bearophile > How about just providing a freeze method on `obje

Re: Converting a string to an array?

2006-01-12 Thread Xavier Morel
Tim Chase wrote: > The closest hack I could come up with was > > import random > s = "abcdefg" > a = [] > a.extend(s) > random.shuffle(a) > s = "".join(a) > > This lacks the beauty of most python code, and clearly feels like > there's somethign I'm missing. I

Re: More than you ever wanted to know about objects [was: Is everything a refrence or isn't it]

2006-01-15 Thread Xavier Morel
Alex Martelli wrote: > Steve Holden <[EMAIL PROTECTED]> wrote: >... >>> 3. If two objects are equal with "==", does that >>> mean their values are the same? >> Almost universally, yes, although if you know enough about how the >> interpreter works "under the hood" you can define the response

Re: instance attributes not inherited?

2006-01-16 Thread Xavier Morel
John M. Gabriele wrote: > I'm having a hard time finding the documentation to the super() function. > I checked the language reference ( http://docs.python.org/ref/ref.html ) > but didn't find it. Can someone please point me to the relevant docs on > super? > > help( super ) doesn't give much info

Re: Arithmetic sequences in Python

2006-01-16 Thread Xavier Morel
Paul Rubin wrote: > There's something to be said for that. Should ['a'..'z'] be a list or > a string? To me, the most obvious result would be either a range object as a result, or always a list/generator of objects (to stay perfectly consistent). If a range of numbers translate into a list of nu

Re: OT: excellent book on information theory

2006-01-16 Thread Xavier Morel
Tim Peters wrote: > Non-English translations have real challenges, and because this series > is more popular than the Python Reference Manual these days, there's a > lot of fascinating info to be found. For example, I think the > Japanese translator deserves a Major Award for their heroic attempt

Re: Arithmetic sequences in Python

2006-01-16 Thread Xavier Morel
Steven D'Aprano wrote: > On Mon, 16 Jan 2006 12:51:58 +0100, Xavier Morel wrote: > >> For those who'd need the (0..n-1) behavior, Ruby features something that >> I find quite elegant (if not perfectly obvious at first), (first..last) >> provides a range from

Re: Arithmetic sequences in Python

2006-01-16 Thread Xavier Morel
Steven D'Aprano wrote: > On Mon, 16 Jan 2006 12:51:58 +0100, Xavier Morel wrote: > >> For those who'd need the (0..n-1) behavior, Ruby features something that >> I find quite elegant (if not perfectly obvious at first), (first..last) >> provides a range from

Re: forced spaces when inserting a variable between strings

2006-01-17 Thread Xavier Morel
mjteigen wrote: > I'm very new at Python, but have been trying it in conjunction with > CGI. I've encountered a problem that I'm pretty sure is a trivial one, > but I don't know enough Python to work it out. Here's an example. > Imagine that I have a file named "5.jpg" in the same directory as this

Re: Arithmetic sequences in Python

2006-01-17 Thread Xavier Morel
Paul Rubin wrote: > I don't think this is a valid objection. Python is already full of > syntactic sugar like indentation-based block structure, infix > operators, statements with keyword-dependent syntax, etc. It's that > very sugar that attracts programmers to Python away from comparatively > s

Re: How to generate graphics dynamically on the web using Python CGI script?

2006-01-20 Thread Xavier Morel
Steve Holden wrote: > Debashis Dey wrote: >> Hello, >> >> I have a python CGI program. I would like to show a graph within a HTML >> plage. I would like to dynamically generate the graph using the python >> CGI script on the web server side and send it to the browser. >> >> My question is how

Re: How to generate graphics dynamically on the web using Python CGI script?

2006-01-20 Thread Xavier Morel
Steve Holden wrote: > Luiz Geron wrote: >> I don't have experience on this, but I think that you can make the >> script return the image "contents" directly to the img tag, without >> passing it to a img file, so you can use something like this: >> >> >> >> wich saves some processing and I/O. >> >

Re: Converting date to milliseconds since 1-1-70

2006-01-26 Thread Xavier Morel
NateM wrote: > Thank you! If I am reading in dates as strings from a text file, like > "5/11/1998", how do I convert that to a format I can pass into mktime? > Thanks again. > Check time.strptime() -- http://mail.python.org/mailman/listinfo/python-list

Re: Decoupling the version of the file from the name of the module.

2006-01-28 Thread Xavier Morel
[EMAIL PROTECTED] wrote: > I'm a newbie experimenting with Python. I want to incrementally develop > a module called 'circle'. The problem is now that the file name is used > for two purposes. To keep track of the version number and as the name > for the module. So when I develop the first version

Re: Decoupling the version of the file from the name of the module.

2006-01-29 Thread Xavier Morel
[EMAIL PROTECTED] wrote: > Now suppose I have make a new version with __version__ = 1.1. What > shall I call this file and (I don't want to overwrite the old file if I > need to go back to it) how do I import it from the shell. Your advice > sounds nice, but I would appreciate if you could give me

Re: Question about idioms for clearing a list

2006-01-31 Thread Xavier Morel
Steven Watanabe wrote: > I know that the standard idioms for clearing a list are: > > (1) mylist[:] = [] > (2) del mylist[:] > > I guess I'm not in the "slicing frame of mind", as someone put it, but > can someone explain what the difference is between these and: > > (3) mylist = [] > >

Re: classmethod and instance method

2006-02-02 Thread Xavier Morel
[EMAIL PROTECTED] wrote: > Hi, > > I'm trying to write a method that needs to know both the class name and > the instance details > > Any suggestions? > What's the point of using a classmethod and an explicit cls argument when you can get the class object from the instance itself? >>> class

Re: Python on Windows

2006-02-03 Thread Xavier Morel
Simon Faulkner wrote: > I've just written my first (simple) WxPython program - yy! > > What would folks suggest is the easiest way to package it to run on > other windows PCs? > > I would love a single .exe file that would run without ANY OTHER FILES > even if it was 50 Mb! > > TIA > > >

Re: classmethod and instance method

2006-02-03 Thread Xavier Morel
[EMAIL PROTECTED] wrote: > Yes that's better. Didn't know about the __class__ attribute. I > thought there must be a way to access this but couldn't find it in the > docs. > > Thanks, > > Andy > dir(), help() and the interactive interpreter (IDLE or CLI) are your best friends. Any time you w

Re: Python on Windows

2006-02-04 Thread Xavier Morel
Grant Edwards wrote: > Definitely. Nobody does single .exe file windows programs > anymore. A single-file installer is almost as easy. > uTorrent, Process Explorer or Media Player Classic are single .exe windows programs. Granted, most of them are under-150kb-works-of-arts, but MPC isn't (well

Re: re.search slashes

2006-02-04 Thread Xavier Morel
Scott David Daniels wrote: > pyluke wrote: >> I'm parsing LaTeX document and want to find lines with equations blocked >> by "\[" and "\]", but not other instances of "\[" like "a & b & c \\[5pt]" >> so, in short, I was to match "\[" but not "\\]" I've tried: >> check_eq = re.compile('(?!\%\

Re: Importing a class, please help...

2006-02-05 Thread Xavier Morel
anon wrote: > Would somebody please drop me a hint, please? > Yeah, the definition of "JAR" is Java ARchive, why the hell would a Python script be able to read a JAR in the first place (truth is it is, a JAR file is nothing but a renamed ZIP, therefore the zipfile module allows you to read it's

Re: Learning Python

2006-02-05 Thread Xavier Morel
Byte wrote: > x = input(raw_input("Please enter your name: ")) > if x==myself: print 'OK' > > It kinda works - I can get to the please enter your name bit but then > it simply reprints your input as output. Someone please HELP! > --> C:\>python Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.13

Re: Learning Python

2006-02-05 Thread Xavier Morel
Byte wrote: > p.s. Xavier Morel, you seem to be using Windows, not Linux > I don't see how this may even remotely be relevant, Python is cross platform and (mostly) works the same regardless of the OS > I got > the idea of stacking input on a raw_input from the official P

Re: Learning Python

2006-02-05 Thread Xavier Morel
Byte wrote: > http://docs.python.org/tut/node6.html#SECTION00610 > --> >>> x = int(raw_input("Please enter an integer: ")) <-- Unless my eyes fail me, it's written "int", not "input", the goal of this line is to convert the return value of raw_input (a string) into an integer.

Re: Learning Python

2006-02-05 Thread Xavier Morel
Byte wrote: > Assumption. Im also new to programing, so could do something stupid > like think a Windows path is a command/input/etc. (really, ive done > things like that before.) > Don't assume anything when you have no reason to, and especially don't assume that a cross-platform programming lan

Re: Learning Python

2006-02-05 Thread Xavier Morel
Byte wrote: >> parse the expression, extract the operands and the operation, apply the > operation to the operands > > How? Give me some example code, but please keep it simple. > >> are you trying to code a calculator? > > Not intending to, just trying to learn Python. Suppose what i'm trying >

Re: Importing a class, please help...

2006-02-05 Thread Xavier Morel
Jorgen Grahn wrote: > You are rude to an obvious newbie here ... please keep in mind that today's > stupid newbies are tomorrow's Python professionals. > I didn't mean to be rude and apologize if that's the way it came out. > Maybe he /is/ running Jython and failed to explain that properly? >

Re: Learning Python

2006-02-05 Thread Xavier Morel
Byte wrote: > I asked to keep it simple! Anyway, ill try Dive into Python, thanks > It is simple, merely explicit and with some details. -- http://mail.python.org/mailman/listinfo/python-list

Re: translating PHP to Python

2006-02-05 Thread Xavier Morel
Dave wrote: > Anyone familiar with PHP? I'm trying to make a translation. In PHP you > can get the current object's name by going like this: > > get_class(item) == 'ClassName' > > I've tried type(item), but since I can't be sure if I'll be in __main__ > or as a child object, I can't guarantee wha

Re: Dual Core outlook

2006-02-07 Thread Xavier Morel
malv wrote: > Of course, multiprocessing has been used for many years but this always > involved a much higher level of sophistication on the part of the > designers. This point seems to be largely hidden from the public, > ignorant and semi-ignorant, by the chip manufacturers. > Will new languages

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

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

  1   2   >