Re: iterator question

2006-09-26 Thread George Sakkis
Neil Cerutti wrote: > On 2006-09-26, Neal Becker <[EMAIL PROTECTED]> wrote: > > Any suggestions for transforming the sequence: > > > > [1, 2, 3, 4...] > > Where 1,2,3.. are it the ith item in an arbitrary sequence > > > > into a succession of tuples: > > > > [(1, 2), (3, 4)...] > > > > In other wo

Re: iterator question

2006-09-26 Thread George Sakkis
Steve Holden wrote: > George Sakkis wrote: > > Neil Cerutti wrote: > > > > > >>On 2006-09-26, Neal Becker <[EMAIL PROTECTED]> wrote: > >> > >>>Any suggestions for transforming the sequence: > >>> > >>>[1, 2, 3, 4...

Re: Makin search on the other site and getting data and writing in xml

2006-09-26 Thread George Sakkis
[EMAIL PROTECTED] wrote: > I dont mean google > i dont mean onelook.com > > these are only examples > > i hop eyou understand what i mean Apparently, *you* don't understand what they're trying to tell you. It roughly boils down to the following: - All (except perhaps the most trivial small) site

Re: A critique of cgi.escape

2006-09-26 Thread George Sakkis
Lawrence D'Oliveiro wrote: > In message <[EMAIL PROTECTED]>, George > Sakkis wrote: > > > Lawrence D'Oliveiro wrote: > > > >> Fredrik Lundh wrote: > >> > you're not the designer... > >> > >> I don't have to be.

Re: Top and Bottom Values [PEP: 326]

2006-09-27 Thread George Sakkis
Antoon Pardon wrote: > What bothers me a bit about the rejection of PEP 326 is that one of the > reasons stated is: > > http://mail.python.org/pipermail/python-dev/2004-January/042306.html > > - it is easily implemented when you really need it > > Well I thought it would simplify some things f

Re: pythonol

2006-09-27 Thread George Sakkis
John Martin wrote: > 'pythonol' is a program for learning spanish. I think it's a really great > program. Unfortunately it ceased to work when I moved to SuSE 10 and 10.1 . > The author makes it clear on her website that she has devoted all the time > she's prepared to and won't maintain it. I thi

Re: Questions on Using Python to Teach Data Structures and Algorithms

2006-09-27 Thread George Sakkis
efrat wrote: > 1. What exactly is a Python list? If one writes a[n], then is the > complexity Theta(n)? If this is O(1), then why was the name "list" > chosen? If this is indeed Theta(n), then what alternative should be > used? (array does not seem suited for teaching purposes.) Indexing for pyth

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread George Sakkis
Gabriel Genellina wrote: > At Thursday 28/9/2006 22:07, Lawrence D'Oliveiro wrote: > > >How about this: (where n is the integer you want to convert): > > > > "".join([["0", "1"][(1 << i & n) != 0] for i in > > range(int(math.ceil(math.log(n, 2))) - 1, -1, -1)]) > > Uhm... so to generate a bina

Re: Can string formatting be used to convert an integer to its binary form ?

2006-09-28 Thread George Sakkis
Steve Holden wrote: > MonkeeSage wrote: > > So far as unobfuscated versions go, how about the simple: > > > > def to_bin(x): > > out = [] > > while x > 0: > > out.insert(0, str(x % 2)) > > x = x / 2 > > return ''.join(out) > > > > Regards, > > Jordan > > > >>> to_bin(0) > '' > > 6/

Re: How to iterate through a sequence, grabbing subsequences?

2006-09-29 Thread George Sakkis
Matthew Wilson wrote: > I wrote a function that I suspect may already exist as a python builtin, > but I can't find it: > > def chunkify(s, chunksize): > "Yield sequence s in chunks of size chunksize." > for i in range(0, len(s), chunksize): > yield s[i:i+chunksize] > > I wrote thi

Re: How to query a function and get a list of expected parameters?

2006-09-29 Thread George Sakkis
Matthew Wilson wrote: > I'm writing a function that accepts a function as an argument, and I > want to know to all the parameters that this function expects. How can > I find this out in my program, not by reading the source? > > For example, I would want to know for the function below that I hav

Re: Automatic methods in new-style classes

2006-09-29 Thread George Sakkis
Ben Cartwright wrote: > [EMAIL PROTECTED] wrote: > > Hey, I have the following code that has to send every command it > > receives to a list of backends. > > > I would like to write each method like: > > > > flush = multimethod() > > Here's one way, using a metaclass: Or if you don't mind a

Re: Overwrite only one function with property()

2006-11-18 Thread George Sakkis
Kai Kuehne wrote: > Hi list! > It is possible to overwrite only one function with the property-function? > > x = property(getx, setx, delx, 'doc') > > I just want to overwrite setx, but when I set the others to None, > I can't read and del the member. Any ideas or is this not possible? There are

Re: Trying to understand Python objects

2006-11-21 Thread George Sakkis
James Stroud wrote: > walterbyrd wrote: > > Reading "Think Like a Computer Scientist" I am not sure I understand > > the way it describes the way objects work with Python. > > > > 1) Can attributes can added just anywhere? I create an object called > > point, then I can add attributes any time, an

Re: Trying to understand Python objects

2006-11-23 Thread George Sakkis
Bruno Desthuilliers wrote: > AFAIK, everything you do with old-style classes can be done with new-style > ones. The only thing I occasionally (or rather rarely) miss about old-style classes is instance-specific special methods: >>> class C: ... def __init__(self,x): ... self.__getit

Re: Python script and C++

2006-11-27 Thread George Sakkis
Thuan Seah Tan wrote: > Hi all, > > I am new to python and currently I am working on a traffic simulation > which I plan to define the various agents using scripting. It's kind of like > scripting for non-playable character in games. I am thinking of using python > for this but I am concerned

Re: Remarkable results with psyco and sieve of Eratosthenes

2006-11-29 Thread George Sakkis
Will McGugan wrote: > > #!/usr/bin/python -OO > > import math > > import sys > > import psyco > > > > psyco.full() > > > > def primes(): > > primes=[3] > > for x in xrange(5,1000,2): > > maxfact = int(math.sqrt(x)) > > flag=True > > for y in primes: > >

Re: More elegant to get a name: o.__class__.__name__

2006-12-01 Thread George Sakkis
Carl Banks wrote: > alf wrote: > > Hi, > > is there a more elegant way to get o.__class__.__name__. For instance I > > would imagine name(o). > > def name_of_type(o): > return o.__class__.__name__ > > name_of_type(o) > > > Carl Banks > > P.S. name(o) suggests it's the name of the object, not t

Re: global name 'self' is not defined

2006-12-02 Thread George Sakkis
Evan wrote: > Hi > > I have a short script that makes 2 calls to methods in another script > as follows: > > import canPlaces as canp > > callOne=canp.addMe(3,5) > callTwo=canp.estocStn() > > The 2 methods in the second script are: > > def addMe(a,b) >sumAb=a+b >return sumAb > > def

Re: About alternatives to Matlab

2006-12-03 Thread George Sakkis
Jon Harrop wrote: > Ok. Perhaps starting a Python JIT in something like MetaOCaml or Lisp/Scheme > would be a good student project? I guess for a student project it's not that important, but if you have higher ambitions, make sure you read http://dirtsimple.org/2005/10/children-of-lesser-python.h

Re: Factory pattern implementation in Python

2006-12-04 Thread George Sakkis
[EMAIL PROTECTED] wrote: > Hi, > > I need to parse a binary file produced by an embedded system, whose > content consists in a set of events laid-out like this: > > ... > > Every "event" is a single byte in size, and it indicates how long is > the associated "data". Thus, to parse all events

Re: Ensure a variable is divisible by 4

2006-12-04 Thread George Sakkis
[EMAIL PROTECTED] wrote: > I am sure this is a basic math issue, but is there a better way to > ensure an int variable is divisible by 4 than by doing the following; > > x = 111 > x = (x /4) * 4 > > Just seems a bit clunky to me. if x % 4 == 0: # x is divisible by 4 George -- http://mail.pyt

Re: Factory pattern implementation in Python

2006-12-04 Thread George Sakkis
Romulo A. Ceccon wrote: > George Sakkis wrote: > > > If you actually intend to > > 1) name your Event subclasses Evt1, Evt2, ... EvtN and not give more > > descriptive (but unrelated to the magic event number) names > > No, those names are just an example. The act

Re: per instance descriptors

2006-12-06 Thread George Sakkis
Simon Bunker wrote: > Hi I have code similar to this: > > class Input(object): > > def __init__(self, val): > self.value = val > > def __get__(self, obj, objtype): > return self.value > > def __set__(self, obj, val): > # do some checking... only accept flo

Re: per instance descriptors

2006-12-07 Thread George Sakkis
[EMAIL PROTECTED] wrote: > George Sakkis wrote: > > Simon Bunker wrote: > > > > > Hi I have code similar to this: > > > > > > class Input(object): > > > > > > def __init__(self, val): > > > self.value = val &g

Re: A Call to Arms for Python Advocacy

2006-12-07 Thread George Sakkis
Jeff Rush wrote: > These works are to be formed into advocacy kits for various audiences. So far > we have the following ideas for kits: > >- College Student's Python Advocacy Kit >- IT Department Python Advocacy Kit >- University Educator's Python Advocacy Kit >- K-12 Educator's

Re: Common Python Idioms

2006-12-07 Thread George Sakkis
Danny Colligan wrote: > > Is there a list somewhere listing those not-so-obvious-idioms? > > I don't know about lists of not-so-obvious idioms, but here's some > gotchas (there may be some overlap with what you're asking about): > > http://zephyrfalcon.org/labs/python_pitfalls.html > http://www.fer

Re: Common Python Idioms

2006-12-08 Thread George Sakkis
Steven D'Aprano wrote: > On Thu, 07 Dec 2006 13:52:33 -0800, George Sakkis wrote: > > > I'm surprized that none of these pages mentions the incompatible type > > comparison gotcha: > > > >>>> 5 < "4" > > True > > > >

Re: autoadd class properties

2006-12-08 Thread George Sakkis
manstey wrote: > I have a ClassWrapper that wraps around a third party database object. > Each database object has a set of properties, like columns in a > relational database. > > I want my wrapper to generate a property for each database object and > load its value into it. > > Thus, in my datab

Re: I think Python is a OO and lite version of matlab

2006-12-08 Thread George Sakkis
Allen wrote: > Does anyone agree with me? > If you have used Matlab, welcome to discuss it. Sure, and earth is a heavy version of a basketball. If all you have is a hammer... George -- http://mail.python.org/mailman/listinfo/python-list

Re: merits of Lisp vs Python

2006-12-08 Thread George Sakkis
Alex Mizrahi wrote: > (message (Hello 'Istvan) > (you :wrote :on '(8 Dec 2006 06:11:20 -0800)) > ( > > ??>> seems to show that Python is a cut down (no macros) version of Lisp > ??>> with a worse performance. > > IA> or maybe it shows that Lisp is an obfuscated version of Python > > hell no, l

Re: merits of Lisp vs Python

2006-12-08 Thread George Sakkis
André Thieme wrote: > On the other hand can I see difficulties in adding macros to Python, > or inventing a new object system, or adding new keywords without > changing the sources of Python itself. Actually, an even bigger difficulty is the rejection of programmable syntax by Guido, both for the

Re: merits of Lisp vs Python

2006-12-08 Thread George Sakkis
[EMAIL PROTECTED] wrote: > Okay, since everyone ignored the FAQ, I guess I can too... > > Mark Tarver wrote: > > How do you compare Python to Lisp? What specific advantages do you > > think that one has over the other? > > (Common) Lisp is the only industrial strength language with both pure > com

Re: merits of Lisp vs Python

2006-12-08 Thread George Sakkis
Ken Tilton wrote: > George Sakkis wrote: > > [EMAIL PROTECTED] wrote: > > > >>Okay, since everyone ignored the FAQ, I guess I can too... > >> > >>Mark Tarver wrote: > >> > >>>How do you compare Python to Lisp? What sp

Re: autoadd class properties

2006-12-08 Thread George Sakkis
manstey wrote: > We've looked at them a little. Cache is a native OO dbase, so there is > no ORM required. Cache does that for you behind the scenes if you need > it to. What I want is to translate Cache classes and properties into > Python classes and properties. We can only use class wrappers, b

Re: merits of Lisp vs Python

2006-12-11 Thread George Sakkis
Cliff Wells wrote: > On Sat, 2006-12-09 at 00:26 -0800, hankhero wrote: > > > The Common-Lisp object systems has all and more OO-features, some which > > you never probably have thought of before. Here's one: > > Inheritance lets you specialise a method so a rectangle and a circle > > can have a d

Re: object data member dumper?

2006-12-12 Thread George Sakkis
tom arnall wrote: > >object data member dumper? > >George Sakkis george.sakkis at gmail.com > >Wed Nov 8 03:42:47 CET 2006 > > > tom arnall wrote: > > > > > Bruno Desthuilliers wrote: > > > > > > > tom arnall a écrit : > > >

Re: merits of Lisp vs Python

2006-12-12 Thread George Sakkis
Robert Uhl wrote: > o Macros > > As mentioned above, macros can make one's life significantly nicer. I > use Python a lot (it's currently a better choice than Lisp for many of > the problems I face), and I find myself missing macros all the time. > The ability to take some frequently-used idiom a

Frame hacking

2006-12-12 Thread George Sakkis
I wonder if the following is possible: def inject_n_call(func, **kwds): '''Call func by first updating its locals with kwds.''' def f(): return x*y >>> inject_n_call(f, x=3, y=4) 12 I've been playing with sys.settrace, updating frame.f_locals in the trace function, but it doesn't seem t

Re: Frame hacking

2006-12-12 Thread George Sakkis
Gabriel Genellina wrote: > On 12 dic, 17:46, "George Sakkis" <[EMAIL PROTECTED]> wrote: > > > I wonder if the following is possible: > > > > def inject_n_call(func, **kwds): > > '''Call func by first updating its locals with

Re: merits of Lisp vs Python

2006-12-12 Thread George Sakkis
Bill Atkins wrote: > greg <[EMAIL PROTECTED]> writes: > > > When moving a set of statements in Python, you > > are usually selecting a set of complete lines, > > cutting them out and then pasting them in > > between two other lines somewhere else. > > You're missing Ken's point, which is that in L

Re: Frame hacking

2006-12-13 Thread George Sakkis
George Sakkis wrote: > Gabriel Genellina wrote: > > On 12 dic, 17:46, "George Sakkis" <[EMAIL PROTECTED]> wrote: > > > > > I wonder if the following is possible: > > > > > > def inject_n_call(func, **kwds): > > > '

ANN: Pyflix-0.1

2006-12-14 Thread George Sakkis
Hi there, I'm happy to announce Pyflix, a small Python package that provides an easy entry point for those wishing to get up and running at the Netflix Prize competition (http://www.netflixprize.com/). For those who are not aware of it, the Netflix Prize challenge is to write a recommendation algo

Re: Property error

2006-12-15 Thread George Sakkis
king kikapu wrote: > Your example Dennis, work as expected. I understand the mistake i have > made. But when i try to fix the original code usihn @property now, it > gives me the same error. > So, here it is: > > class Person(object): > _age = 0 > > @property > def age(): > def

Re: tuple.index()

2006-12-15 Thread George Sakkis
Christoph Zwerschke wrote: > The statement "if you are looking for index() or count() for your > tuples, you're using the wrong container type" is too extreme I think. I > would agree with "it *may indicate* that you should better use lists". And also if that statement was correct, I would argue

Re: Property error

2006-12-15 Thread George Sakkis
king kikapu wrote: > Your example Dennis, work as expected. I understand the mistake i have > made. But when i try to fix the original code usihn @property now, it > gives me the same error. > So, here it is: > > class Person(object): > _age = 0 > > @property > def age(): > def

Re: Property error

2006-12-15 Thread George Sakkis
king kikapu wrote: > Your example Dennis, work as expected. I understand the mistake i have > made. But when i try to fix the original code usihn @property now, it > gives me the same error. > So, here it is: > > class Person(object): > _age = 0 > > @property > def age(): > def

Re: Property error

2006-12-15 Thread George Sakkis
king kikapu wrote: > Your example Dennis, work as expected. I understand the mistake i have > made. But when i try to fix the original code usihn @property now, it > gives me the same error. > So, here it is: > > class Person(object): > _age = 0 > > @property > def age(): > def

urllib.unquote and unicode

2006-12-18 Thread George Sakkis
The following snippet results in different outcome for (at least) the last three major releases: >>> import urllib >>> urllib.unquote(u'%94') # Python 2.3.4 u'%94' # Python 2.4.2 UnicodeDecodeError: 'ascii' codec can't decode byte 0x94 in position 0: ordinal not in range(128) # Python 2.5 u'\x9

Re: urllib.unquote and unicode

2006-12-19 Thread George Sakkis
Fredrik Lundh wrote: > George Sakkis wrote: > > > The following snippet results in different outcome for (at least) the > > last three major releases: > > > >>>> import urllib > >>>> urllib.unquote(u'%94') > > > > # P

Re: def index(self):

2006-12-20 Thread George Sakkis
Gert Cuykens wrote: > > > class HelloWorld(object): > > > @cherrypy.exposed > > > def index(self): > > >return "Hello World" > > do i have to write @cherrypy.exposed before every def or just once for > all the def's ? and why not write something like @index.exposed ? > > in other wo

Re: Decorator for Enforcing Argument Types

2006-12-21 Thread George Sakkis
John Machin wrote: > Bruno Desthuilliers wrote: > > > > > Python is dynamic, and fighting against the language is IMHO a really > > bad idea. The only places where theres a real need for this kind of > > stuff are when dealing with the "outside world" (IOW : inputs and > > outputs). And then packa

Re: Decorator for Enforcing Argument Types

2006-12-22 Thread George Sakkis
Duncan Booth wrote: > "John Machin" <[EMAIL PROTECTED]> wrote: > > >> > if isinstance( > >> > action_for_type1(... > >> > # big snip > >> > elif isinstance(... > >> > action_typeN( ... > >> > # no else statement > >> > >> Ouch.. someone must have skipped his/her OO class... > > > > Qui

Re: Decorator for Enforcing Argument Types

2006-12-22 Thread George Sakkis
John Machin wrote: > Peter Wang wrote: > > Bruno Desthuilliers wrote: > > > > > > Python is dynamic, and fighting against the language is IMHO a really > > > bad idea. The only places where theres a real need for this kind of > > > stuff are when dealing with the "outside world" (IOW : inputs an

Re: array of class

2007-01-02 Thread George Sakkis
Bruno Desthuilliers wrote: > FWIW, I guess that what you want here may looks like this: > > class Word(object): >def __init__(self, word=''): > self._word = word >def __repr__(self): > return "" % (self._word, id(self)) > > > words = [] > for w in ['this', 'is', 'probably', 'what

Re: Sorting on multiple values, some ascending, some descending

2007-01-03 Thread George Sakkis
dwelden wrote: > I have successfully used the sort lambda construct described in > http://mail.python.org/pipermail/python-list/2006-April/377443.html. > However, how do I take it one step further such that some values can be > sorted ascending and others descending? Easy enough if the sort values

Re: Recommendations (or best practices) to define functions (or methods)

2007-01-07 Thread George Sakkis
vizcayno wrote: > Hello: > Need your help in the "correct" definition of the next function. If > necessary, I would like to know about a web site or documentation that > tells me about best practices in defining functions, especially for > those that consider the error exceptions management. > I h

Re: fairly large webapp: from Java to Python. experiences?

2006-02-06 Thread George Sakkis
> Any tips, stories, recommendations, and/or experiences are most > welcome. Just one suggestion, read the article "Things You Should Never Do, Part I" first ( http://www.joelonsoftware.com/articles/fog69.html). Quoting from the article: (Netscape made) "the *single worst strategic mistak

Re: Is Python good for web crawlers?

2006-02-07 Thread George Sakkis
You may want to start from HarvestMan: http://harvestman.freezope.org/ George -- http://mail.python.org/mailman/listinfo/python-list

Re: os.walk() dirs and files

2006-02-08 Thread George Sakkis
rtilley wrote: > Duncan Booth wrote: > >> How about just concatentating the two lists: >> >>> for root, dirs, files in os.walk(path): >> >>for fs_object in files + dirs: >> >>> ADD fs_object to dictionary > > > Thank you Duncan! that solves the problem perfectly! Or a bit more effi

Re: breaking from loop

2006-02-10 Thread George Sakkis
Using the (non-standard yet) path module (http://www.jorendorff.com/articles/python/path/), your code can be simplified to: from path import path, copy def copy_first_match(repository, filename, dest_dir): try: first_match = path(repository).walkfiles(filename).next() except StopI

Re: Writing a Web Robot in Python

2006-02-13 Thread George Sakkis
You'd probably get more results by searching for "web crawlers" or "web spiders". You may start from here: http://harvestman.freezope.org/faq.html HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Rapid web app development tool for database

2006-03-01 Thread George Sakkis
Is there any tool in python (or with python bindings) like Oracle Application Express, former HTML DB (http://www.oracle.com/technology/products/database/application_express/index.html) ? Ideally it should be dbms-agnostic, e.g. by using SQLObject to talk to the database. The closest I can think of

Re: How can I find the remainder when dividing 2 integers

2006-03-01 Thread George Sakkis
Learn about ther itertools module, one of the most useful and elegant modules in the standard library (http://docs.python.org/lib/module-itertools.html): import itertools as it colors = ["#ff", "#00FF00", "#FF"] words = "Itertools is a pretty neat module".split() for word_color in it.izip(

Re: Numeric/Numarray equivalent to zip ?

2005-05-01 Thread George Sakkis
"Peter Otten" <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > > What's the fastest and most elegant equivalent of zip() in > > Numeric/Numarray between two equally sized 1D arrays ? That is, how to > > combine two (N,)-shaped arrays to one (N,2)

Re: Numeric/Numarray equivalent to zip ?

2005-05-01 Thread George Sakkis
"Peter Otten" <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > > Though not the fastest to execute; using concatenate instead of > > initializing an array from a list [a,a] is more than 2,5 time faster in > > my system (~4.6 vs 11.8 usec per loop a

Re: Inspect Python Classes for instance data information

2005-05-02 Thread George Sakkis
"Tim Henderson" <[EMAIL PROTECTED]> wrote: > Hello > > I want to creat a program that can inspect a set of classes that i have > made and spit out a savable version of these classes. To do this I need > to be able to inspect each class and get all of its instance data as > well as information about

Re: Inspect Python Classes for instance data information

2005-05-02 Thread George Sakkis
> > I have no idea how to do the inspection part of this little > > problem. I could just have each class define its own meathod to > > convert to this format, but that would be a lot of work when i > > could just make one class that solves the problem for all classes. > > Is there a way to do this

Re: How to write this regular expression?

2005-05-04 Thread George Sakkis
This newsgroup is in general very helpful, but there are some exceptions; one of them is when the problem appears blatantly to be a homework. Perhaps if you showed that you worked on it and made some progress, but it's not quite right, someone may help you. George -- http://mail.python.org/mailm

Re: PHPParser pod Zope

2005-05-04 Thread George Sakkis
"bruno modulix" <[EMAIL PROTECTED]> wrote: > Josef Meile wrote: > (snip) > > > > I don't find this two replies funy :-(. I think it is impolite to make > > fun of the OP. > > My intent was not to make fun *of* the OP. Now I'm willing to admit that > my answer may not be as (kindly) funny as intend

Weird UserArray AttributeError (bug ?)

2005-05-06 Thread George Sakkis
I came across a strange error when trying to define a settable property for a new-style subclass of UserArray (Numeric). Here's a shorter example that reproduces the problem: from UserArray import UserArray from math import hypot class Vector(UserArray,object): def __init__(self,x,y):

Re: Getting number of iteration

2005-05-06 Thread George Sakkis
"Florian Lindner" wrote: > Hello, > when I'm iterating through a list with: > > for x in list: > > how can I get the number of the current iteration? > > Thx, > > Florianfor in python 2.3+: for i,x in enumerate(sequence): print "sequence[%d] = %s" %(i,x) George -- http://mail.python.org/

Re: Weird UserArray AttributeError (bug ?)

2005-05-06 Thread George Sakkis
To answer my own question, the error is caused by the __setattr__ defined in UserArray: def __setattr__(self,attr,value): if attr=='shape': self.array.shape=value self.__dict__[attr]=value I'm not sure though how to "undefine" __setattr__ in a subclass so that property

Re: Newbie : checking semantics

2005-05-07 Thread George Sakkis
> What disappoints me is that pyton will happily accept and execute this > code : > > if ( aConditionThatIsFalse ): > AFunctionThatIsntDefined() > > print "Hello world" > > The fact that python doesn't check if the symbol > AFunctionThatIsntDefined is defined, is really bad when you develop bi

cimport from different packages [Pyrex]

2005-05-09 Thread George Sakkis
Does cimport work for importing from different packages in Pyrex ? Here's a minimal example: # in ./foo/bar.pxd cdef class Bar: cdef int i # in ./foo/bar.pyx cdef class Bar: def __init__(self, i): self.i = i # in ./tmp.pyx cimport foo.bar $ pyrexc foo/bar.pyx $ pyrexc tmp.pyx tm

Re: Importing modules

2005-05-11 Thread George Sakkis
"Fredrik Lundh" wrote : > [EMAIL PROTECTED] wrote: > > > To understand a program, however, you need also a flow chart... > > so understand a carefully designed modular component structure, you > have to remove the structure so you can create a flow chart? > > did you perhaps stumble upon a strange

Re: Python Documentation (should be better?)

2005-05-11 Thread George Sakkis
> Cuz I think the Language Reference is really more of a grammer reference and > far too technical to look up simple things like "how to declare a > function". > > I guess what I'm trying to say is that there is no manual (for the language > itself, not the modules). There is just the tutorial tha

Re: Markov chain with extras?

2005-05-16 Thread George Sakkis
> Hi All, > > Could someone show me how to do this? > > I want to generate a list using a Markov chain, however, as well as > using the previous two items in the list to decide the current choice I > want the decision to be also dependant on an item at the current > position in another list. > > I

Re: Parsing text into dates?

2005-05-16 Thread George Sakkis
"Thomas W" wrote: > I'm developing a web-application where the user sometimes has to enter > dates in plain text, allthough a format may be provided to give clues. > On the server side this piece of text has to be parsed into a datetime > python-object. Does anybody have any pointers on this? > >

Re: Reg Date string conversion into timestamp function

2005-05-16 Thread George Sakkis
"praba kar" <[EMAIL PROTECTED]> wrote: > > Dear All, > > I have doubt regarding date string to time > conversion function. In Python I cannot find flexible > date string conversion function like php strtotime. I > try to use following type > function > 1) parsedate function failed if a date s

Re: Parsing text into dates?

2005-05-16 Thread George Sakkis
"John Machin" <[EMAIL PROTECTED]> wrote: > On 16 May 2005 17:51:31 -0700, "George Sakkis" <[EMAIL PROTECTED]> > wrote: > > > >#=== > > > >def parseDateTime(string, USA=Fal

Re: Like Christ PBBUH Prayed

2005-05-16 Thread George Sakkis
"flamesrock" wrote: > I don't understand.. why is everyone talking about christ on > comp.lang.python? Isn't this not the place? > Maybe they know something we don't. -- http://mail.python.org/mailman/listinfo/python-list

Re: Is Python suitable for a huge, enterprise size app?

2005-05-18 Thread George Sakkis
"Ivan Van Laningham" wrote: > What you're going to run into are two major stumbling blocks. One, > Python's got no credibility with management types unless the > credibility's already there. "Python? Never heard of it. Tell me > about it. ... Oh, it's interpreted, is it? Interesting." You

Re: Is Python suitable for a huge, enterprise size app?

2005-05-18 Thread George Sakkis
"Kay Schluehr" wrote: > > Think about it: if the > > project fails (and that's quite likely for huge projects, not dark > > humour) and you've done it in python, everyone will blame python and > > you who chose it; java OTOH belongs in the realm of "standard > business > > practices", so in a way

Re: help with generators

2005-05-19 Thread George Sakkis
"Steven Bethard" wrote: > It would help if you explained what you expected. But here's code that > prints about the same as your non-generator function. > > py> def bin(n): > ... s = [] > ... def bin(n): > ... if n == 0: > ... yield s > ... else: > ...

Re: Python analog of Ruby on Rails?

2005-05-25 Thread George Sakkis
"Christopher J. Bottaro" wrote: > Cool signature, can anyone do a Python one that I can leech? =) > > -- C > Here's the transliteration in python for your address: python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" Cheer

Re: smart logging and the "inspect" module ...

2005-05-28 Thread George Sakkis
"Darran Edmundson" wrote: > I was playing around with the inspect module the other day > trying to write a quick and dirty "smart" logger. By this I mean > that writing a message to the global log would also yield some > info about the calling scope. If you look at my function "test" > below, I'd

Re: Iterate through a list calling functions

2005-06-05 Thread George Sakkis
David Pratt wrote: > Hi. I am creating methods for form validation. Each validator has its > own method and there quite a number of these. For each field, I want > to evaluate errors using one or more validators so I want to execute > the appropriate validator methods from those available. I am

Re: Annoying behaviour of the != operator

2005-06-08 Thread George Sakkis
"Jordan Rastrick" wrote: > I'd suggest the only nessecary change is, if objects a,b both define > __eq__ and not __ne__, then a != b should return not (a == b) > > If a class defines __ne__ but not __eq__, well that seems pretty > perverse to me. I don't especially care one way or another how that

Re: Abstract and concrete syntax

2005-06-08 Thread George Sakkis
"Greg Ewing" wrote: > > More generally, I think there is no abstract distinction between > > statements and expressions. Everything is an expression, can be evaluated > > to a value. > > That's true in a functional language, but Python is not a > functional language. In imperative programming, of

Re: Annoying behaviour of the != operator

2005-06-10 Thread George Sakkis
"Rocco Moretti" wrote: > One way to handle that is to refuse to sort anything that doesn't have a > "natural" order. But as I understand it, Guido decided that being able > to sort arbitrary lists is a feature, not a bug. He has changed his mind since then (http://mail.python.org/pipermail/python

Re: Abstract and concrete syntax

2005-06-10 Thread George Sakkis
"Mandus" wrote: > Thu, 09 Jun 2005 03:32:12 +0200 skrev David Baelde: > [snip] > > > > set_callback(obj, > > lambda x: (if a: > >2 > > else: > >3) > > > [snip] > > You can do stuff like this: lambda x: x and 2 or 3 > > Of course, you are st

Re: Abstract and concrete syntax

2005-06-10 Thread George Sakkis
"Kay Schluehr" wrote: > > Thu, 09 Jun 2005 03:32:12 +0200 skrev David Baelde: > > [snip] > > > > > > set_callback(obj, > > > lambda x: (if a: > > >2 > > > else: > > >3) > > > > > [snip] > > > > You can do stuff like this: lambda x: x and 2

Re: Abstract and concrete syntax

2005-06-10 Thread George Sakkis
"Kay Schluehr" wrote: > > You can do stuff like this: lambda x: x and 2 or 3 > > You can also do this > >lambda x: {True:2,False:3}.get(bool(a)) > > which is both beautiful and pythonic. > > Kay Beauty is in the eye of the beholder, and the same holds for 'pythonicity'; IMO both are much less

Re: Structure function

2005-06-10 Thread George Sakkis
> Hello, > > Does anyone have an efficient Python routine for calculating the > structure function? > > > Thanks very much, > > > Daran > [EMAIL PROTECTED] Read this first and come back: http://www.catb.org/~esr/faqs/smart-questions.html#beprecise George -- http://mail.python.org/mailman/listin

Re: How to get/set class attributes in Python

2005-06-12 Thread George Sakkis
"alex23" wrote: > Kalle Anke wrote: > > I'm coming to Python from other programming languages. I like to > > hide all attributes of a class and to only provide access to them > > via methods. > > I'm pretty fond of this format for setting up class properties: > > class Klass(object): > def pro

Re: unittest: collecting tests from many modules?

2005-06-12 Thread George Sakkis
"Jorgen Grahn" wrote: > I have a set of tests in different modules: test_foo.py, test_bar.py and so > on. All of these use the simplest possible internal layout: a number of > classes containing test*() methods, and the good old lines at the end: > > if __name__ == "__main__": > unittest.m

Re: Learning more about "The Python Way"

2005-06-12 Thread George Sakkis
"Kalle Anke" wrote: > [snipped] > > So, I'm looking for advice/information on: > > + How to write "proper" python code instead of > Java/Perl/C/C++/Pascal/Modula-2/etc inspired code > > + The more advanced parts/uses of Python > > + Discussions about the ideas behind different Python > constru

Re: What is different with Python ?

2005-06-12 Thread George Sakkis
"Mike Meyer" wrote: > Andrea Griffini <[EMAIL PROTECTED]> writes: > > On Sat, 11 Jun 2005 21:52:57 -0400, Peter Hansen <[EMAIL PROTECTED]> > > wrote: > > Also concrete->abstract shows a clear path; starting > > in the middle and looking both up (to higher > > abstractions) and down (to the impleme

Re: count string replace occurances

2005-06-12 Thread George Sakkis
"Jeff Epler" wrote: > On Sun, Jun 12, 2005 at 04:55:38PM -0700, Xah Lee wrote: > > if i have > > mytext.replace(a,b) > > how to find out many many occurances has been replaced? > > The count isn't returned by the replace method. You'll have to count > and then replace. > > def count_replace(a, b,

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