Re: Getting method name from within the class method

2006-10-18 Thread George Sakkis
Mitko Haralanov wrote: > On 18 Oct 2006 14:38:12 -0700 > [EMAIL PROTECTED] wrote: > > > >>> class test(object): > > ... def a_method(self,this,that): > > ... print self.a_method.__name__ > > Doing the above will obviously work! > > However, I don't want to have to use the name of the function i

Set operations in Numeric

2006-10-23 Thread George Sakkis
Is there a way to handle numeric (or numarray or numpy) arrays as sets and compute efficiently their intersection, union, etc. ? I hope there is a faster way than s = array(set(A) & set(B)). Can this be done with masked arrays maybe ? I've never used them though and browsing through the docs didn't

Re: Set operations in Numeric

2006-10-23 Thread George Sakkis
Robert Kern wrote: > George Sakkis wrote: > > Is there a way to handle numeric (or numarray or numpy) arrays as sets > > and compute efficiently their intersection, union, etc. ? I hope there > > is a faster way than s = array(set(A) & set(B)). Can this be done with >

Re: Looking for a Python-on-Windows person to help with SpamBayes

2006-10-23 Thread George Sakkis
[EMAIL PROTECTED] wrote: > The bare requirements are: > > * Able to program in Python on Windows (that is, remove my Unix-think > from the OCR bits of code) > > * Use Outlook to read mail (so you can test the changes with the > SpamBayes Outlook plugin) Does "remove my unix-th

Re: question about True values

2006-10-25 Thread George Sakkis
Martin v. Löwis wrote: > [EMAIL PROTECTED] schrieb: > > the string class's "nil" value. Each of the builtin types has such an > > "empty" or "nil" value: > > > > string "" > > list[] > > tuple () > > dict{} > > int

Fatal Python error: deallocating None

2006-10-25 Thread George Sakkis
It's the first time in the three years I've been using python that a program crashes without a nice traceback to give me a clue of what might be wrong. After searching a little, it seems it's one of those hard to get down to cases, so I've no idea where to look for. Briefly what I do is, select som

Re: NumPy 1.0 release

2006-10-26 Thread George Sakkis
Travis E. Oliphant wrote: > We are very pleased to announce the release of NumPy 1.0 available for > download at http://www.numpy.org Congratulations for this great package and the tremendous effort that was put on it! Hopefully with this release, the 'array wars' are over; we may not be able to a

Re: NumPy 1.0 release

2006-10-26 Thread George Sakkis
Robert Kern wrote: > George Sakkis wrote: > > ImportError: > > /usr/local/lib/python2.4/site-packages/numpy/linalg/lapack_lite.so: > > undefined symbol: zheevd_ > > > > Googling for "undefined symbol: zheevd_" returned no hits, at which > > point

High level csv reader

2006-10-31 Thread George Sakkis
It occured to me that most times I read a csv file, I'm often doing from scratch things like assigning labels to columns, mapping fields to the appropriate type, ignoring some fields, changing their order, etc. Before I go on and reinvent the wheel, is there a generic high level wrapper around csv.

Re: High level csv reader

2006-11-01 Thread George Sakkis
[EMAIL PROTECTED] wrote: > George> It occured to me that most times I read a csv file, I'm often > George> doing from scratch things like assigning labels to columns, > George> mapping fields to the appropriate type, ignoring some fields, > George> changing their order, etc. Before I

Re: tips requested for a log-processing script

2006-11-05 Thread George Sakkis
Jaap wrote: > Apart from this I have a configuration file, which contains the list of > itemID's i need to focus on per month. Not all itemID's are relevant for > each month, but for example only every second or third month. All > records in the logfile with other itemID's can be ignored. I have y

Re: simple way to un-nest (flatten?) list

2006-11-05 Thread George Sakkis
djc wrote: > There is I am sure an easy way to do this, but I seem to be brain dead > tonight. So: > > I have a table such that I can do > > [line for line in table if line[7]=='JDOC'] > and > [line for line in table if line[7]=='Aslib'] > and > [line for line in table if line[7]=='ASLIB'

Re: object data member dumper?

2006-11-07 Thread George Sakkis
tom arnall wrote: > Bruno Desthuilliers wrote: > > > tom arnall a écrit : > >> does anyone know of a utility to do a recursive dump of object data > >> members? > >> > > > > What are "object data members" ? (hint: in Python, everything is an > > object - even functions and methods). > > > > What i

Re: unpickling Set as set

2006-11-08 Thread George Sakkis
Nick Vatamaniuc wrote: > The two are not of the same type: > > - > In : import sets > In : s1=sets.Set([1,2,3]) > > In : s2=set([1,2,3]) > > In: type(s1) > Out: > > In : type(s2) > Out: > > In : s1==s2 > Out: False # oops! > > In: s2==set(s1) > Out: True # aha!

Re: how is python not the same as java?

2006-11-09 Thread George Sakkis
how are BMWs not the same with Yugos ? both have four wheels and burn gasoline. -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance Question

2006-11-10 Thread George Sakkis
Gabriel Genellina wrote: > If walking in general, have some common structure, you can put the > "sketch" on Legs and let the derived classes "fill the gaps". This is > known as "Template Method Pattern" - look for it. Or if you'd rather see a concrete example, here's how your toy example would lo

Re: handling many default values

2006-11-11 Thread George Sakkis
Ben Finney wrote: > "Alan Isaac" <[EMAIL PROTECTED]> writes: > > > There are *many* parameters, and the list can change, so I want to > > avoid listing them all in the Param class's __init__ function, using > > the strategy above. > > > > Q1: Is this approach reasonable? > > (This is a newbie

Re: reduce to be removed?

2006-11-12 Thread George Sakkis
Dustan wrote: > Alright, I can see I'm a bit outvoted here. I tried your suggestions > and it worked fine. > > I'll also try to consider in the future that part of the problem might > be lack of information conveyed on my part. If you insist on one-liners, it can be done without sum(), though it

Re: Python 3000 idea -- + on iterables -> itertools.chain

2006-11-12 Thread George Sakkis
Fredrik Lundh wrote: > John Reese wrote: > > > It seems like it would be clear and mostly backwards compatible if the > > + operator on any iterables created a new iterable that iterated > > throught first its left operand and then its right, in the style of > > itertools.chain. > > you do know th

Re: Python 3000 idea -- + on iterables -> itertools.chain

2006-11-13 Thread George Sakkis
Fredrik Lundh wrote: > George Sakkis wrote: > > > The base object class would be one candidate, similarly to the way > > __nonzero__ is defined to use __len__, or __contains__ to use __iter__. > > > > Alternatively, iter() could be a wrapper type (or perhaps mi

Re: Python 3000 idea -- + on iterables -> itertools.chain

2006-11-13 Thread George Sakkis
Carl Banks wrote: > George Sakkis wrote: > > Fredrik Lundh wrote: > > > > > George Sakkis wrote: > > > > > > > The base object class would be one candidate, similarly to the way > > > > __nonzero__ is defined to use __len__, or __contai

Re: Python development time is faster.

2006-11-13 Thread George Sakkis
Steven Bethard wrote: > A simple example from document indexing. Using Java Lucene to index > some documents, you'd write code something like:: > > Analyzer analyzer = new StandardAnalyzer() > IndexWriter writer = new IndexWriter(store_dir, analyzer, true) > for (Value value: value

Re: Array? Please help.

2006-05-28 Thread George Sakkis
Diez B. Roggisch wrote: > George Sakkis schrieb: > > Diez B. Roggisch wrote: > >> Dr. Pastor schrieb: > >>> I need a row of 127 bytes that I will use as a > >>> circular buffer. Into the bytes (at unspecified times) > >>> a mark (0 >>&g

Re: ideas for programs?

2006-05-31 Thread George Sakkis
Brandon McGinty wrote: > Hi, > I've been learning python for the past couple of months and writing misc > scripts here and there, along with some web apps. > I'm wondering if anyone has ideas of programs I might try my hand at making? > I'd appreciate it if they don't use images, because I'm blind

Re: argmax

2006-06-01 Thread George Sakkis
David Isaac wrote: > 1. Why is there no argmax built-in? > (This would return the index of the largest element in a sequence.) I guess because it's not used frequently enough. I've needed argmax/argmin more than once though, so I would welcome them as builtins. > 2. Is this a good argmax (as lon

Re: Allowing zero-dimensional subscripts

2006-06-09 Thread George Sakkis
[EMAIL PROTECTED] wrote: > However, I'm designing another library for > managing multi-dimensional arrays of data. Its purpose is similiar to > that of a spreadsheet - analyze data and preserve the relations between > a source of a calculation and its destination. Sounds interesting. Will it be r

Re: Allowing zero-dimensional subscripts

2006-06-10 Thread George Sakkis
[EMAIL PROTECTED] wrote: > George Sakkis wrote: > > [EMAIL PROTECTED] wrote: > > > > > However, I'm designing another library for > > > managing multi-dimensional arrays of data. Its purpose is similiar to > > > that of a spreadsheet - analyze

Re: Algorithm for Labels like in Gmail

2006-06-10 Thread George Sakkis
[EMAIL PROTECTED] wrote: > Hello there! > > I'm trying to make a simple Contact Manager using python (console > only), however i'm having trouble implementing a division by "Groups" > or "Labels" just like in Gmail. I don't have any real code to post > because all i got now is a raw TXT file holdi

Re: Very newbie programming

2006-06-11 Thread George Sakkis
TheSaint wrote: > Maric Michaud wrote: > > > Le Samedi 10 Juin 2006 17:44, TheSaint a écrit : > > >> > > begin using more explicit variable names. > > Frankly it's a very rooted way of programming, since C64 basic :-) If by 'rooted' you mean old enough, so is 'goto'... Except perhaps for iteratio

Re: question on dict subclassing and overriding __setitems__

2006-06-13 Thread George Sakkis
Eric S. Johansson wrote: > Diez B. Roggisch wrote: > > Or better even > > > >super(subclass, self).__setitem__(key.upper(), value) > > hmm. http://fuhm.net/super-harmful/ Interesting link, didn't know about it. I've always found super() ugly and doubted that it was in practice better

Re: __cmp__ method

2006-06-14 Thread George Sakkis
Jon Clements wrote: > This probably isn't exactly what you want, but, unless you wanted to do > something especially with your own string class, I would just pass a > function to the sorted algorithm. > > eg: > > sorted( [a,b,c], cmp=lambda a,b: cmp(len(a),len(b)) ) > > gives you the below in the

Re: split with "*" in string and ljust() puzzles

2006-06-14 Thread George Sakkis
Serge Orlov wrote: > Sambo wrote: > > I have just (finally) realized that it is splitting and removing > > on single space but that seams useless, and split items > > 1 and 2 are empty strings not spaces?? > > What is useless for you is worth $1,000,000 for somebody else ;) > If you have comma sep

Re: nested functions

2006-06-14 Thread George Sakkis
Ben Finney wrote: > "Gregory Petrosyan" <[EMAIL PROTECTED]> writes: > > > I often make helper functions nested, like this: > > > > def f(): > > def helper(): > > ... > > ... > > > > is it a good practice or not? > > You have my blessing. Used well, it makes for more readable code.

Re: nested functions

2006-06-15 Thread George Sakkis
Duncan Booth wrote: > Fredrik Lundh wrote: > > > George Sakkis wrote: > > > >> It shouldn't come as a surprise if it turns out to be slower, since > >> the nested function is redefined every time the outer is called. > > > > except that it i

Pickling gotcha

2006-06-15 Thread George Sakkis
I stumbled on some weird pickling behavior that after some non-trivial debugging time turned out to be caused by __getstate__ returning an empty dict for some instances. As I found digging through the docs (http://pythondoc.kldp.net/lib/pickle-inst.html), surprisingly __setstate__ is not called nor

Re: any subway web dev experiences

2006-06-18 Thread George Sakkis
a wrote: > subway is pythons ruby on rails competitor > pls tell me if u hav any expereinces > thanks u wanna know reils n subway ur so kewl omg! no expereinces watsoevah, sori dud PS: If you want to be taken seriously, put at least some effort to make a readable english sentence. This is comp.

Re: Calling every method of an object from __init__

2006-06-19 Thread George Sakkis
Rob Cowie wrote: > Hi all, > > Is there a simple way to call every method of an object from its > __init__()? > > For example, given the following class, what would I replace the > comment line in __init__() with to result in both methods being called? > I understand that I could just call each me

Re: crawlers in python with graphing?

2006-06-20 Thread George Sakkis
bryan rasmussen wrote: > Hi, > > Sorry, was imprecise, I meant not save the downloaded page locally. > There probably isn't one though, so I should build one myself. > Probably just need a good crawler that can be set to dump all links > into dataset that I can analyse with R. > > Cheers, > Bryan R

Re: Specifing arguments type for a function

2006-06-20 Thread George Sakkis
Maric Michaud wrote: > Le Mardi 20 Juin 2006 13:28, Maric Michaud a écrit : > > if not getattr(arg, '__iter__') and not getattr(arg, '__getitem__') : > > raise ValueError('Function accepts only iterables') # or error handling > > code > > oops, hasattr of course : > > if not hasattr(arg, '__it

Re: TEST IGNORE

2006-06-20 Thread George Sakkis
David Hirschfield wrote: > Having email trouble... > Having bathroom trouble... can I help myself at your house entrance ? Didn't think so... -- http://mail.python.org/mailman/listinfo/python-list

(Iron)Python on new MS robotics platform

2006-06-22 Thread George Sakkis
"Both remote (PC-based) and autonomous (robot-based) execution scenarios can be developed using a selection of programming languages, including those in Microsoft Visual Studio® and Microsoft Visual Studio Express languages (Visual C#® and Visual Basic® .NET), JScript® and Microsoft IronPython 1.0

Re: Status of optional static typing in Python?

2006-06-22 Thread George Sakkis
Christian Convey wrote: > Perhaps I'm deluded but I don't think so. I'll tell you my situation > and I'd appreciate your take on it... > > I'm looking into the design a network simulator. The simulator has a > few requirements: > > (1) I need to be able to swap in a variety of replacement compon

Re: Specifing arguments type for a function

2006-06-22 Thread George Sakkis
Bruno Desthuilliers wrote: > George Sakkis a écrit : > > This is ok - in theory. In practice I've found that e.g. strings are > > more often than not handled as scalars although they are typically > > iterables. > >>> hasattr('', '__ite

Re: String negative indices?

2006-06-22 Thread George Sakkis
[EMAIL PROTECTED] wrote: > I'm just starting out on Python, and am stumped by what appears an oddity in > the way negative indices are handled. > > For example, to get the last character in a string, I can enter "x[-1]". To > get the 2nd and 3rd to last, I can enter x[-3:-1] etc. This is fine. >

Re: Specifing arguments type for a function

2006-06-22 Thread George Sakkis
Dennis Lee Bieber wrote: > On 22 Jun 2006 16:48:47 -0700, "George Sakkis" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > What does __setitem__ have to do with iterability ? > > It confirms that the object is indexable, and muta

Re: Specifing arguments type for a function

2006-06-23 Thread George Sakkis
Dennis Lee Bieber wrote: > On 22 Jun 2006 22:55:00 -0700, "George Sakkis" <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > > Ok, I'll try once more: What does __setitem__ have to do with > > **iterability**, not mutability or i

Flight search automation

2006-06-23 Thread George Sakkis
I'm trying to use mechanize to fill in a "find a flight" form and then get back the results, but I'm not sure how to make it wait until the results page appears; the response after submitting the form is the "please wait while we are searching for your flights" page. Any ideas ? George -- http:/

Re: Flight search automation

2006-06-23 Thread George Sakkis
o a waiting page, hopefully I can figure them out once I have one working. George > George Sakkis wrote: > > I'm trying to use mechanize to fill in a "find a flight" form and then > > get back the results, but I'm not sure how to make it wait until the > > result

Re: search engine

2006-06-24 Thread George Sakkis
vinodh kumar wrote: > hai all, > i am student of computer science dept. i have planned to > design a search engine in python. i am seeking info about how to > proceed further. > i need to know what r the modules that can be used. There is not a "search engine module" around AFAI

Re: Syntax suggestion.

2006-08-30 Thread George Sakkis
samir wrote: > Saluton! > > Being a fond of Python, I had this idea: Why not making Python a Unix > shell? It's been done; it's called "IPython": http://ipython.scipy.org/doc/manual/manual.html George -- http://mail.python.org/mailman/listinfo/python-list

Re: disgrating a list

2006-09-01 Thread George Sakkis
jwaixs wrote: > Hello, > > How can I disgrate (probably not a good word for it) a list? For > example: > > a = [1,2] > b = 3 > c = [a] + [b] # which makes [[1,2],3] > > Then how can I change c ([[1,2],3]) into [1,2,3]? I have a simple > function for this: > > def flatt

Re: Incremental Progress Report object/closure?

2006-09-01 Thread George Sakkis
Terrence Brannon wrote: > 'lo all, I'm looking for something that gives feedback to the screen > every X iterations, reporting > > Time elapsed: 0:00:00 X,XXX,XXX records done. speed /second. > [Action Label] > > > Such a thingy is useful when one is cranking away at million record > flat f

Re: disgrating a list

2006-09-01 Thread George Sakkis
jwaixs wrote: > Thank you for all your reply and support. Neil's fits the most to me. I > shrinked it to this function: > > def flatten(x): > for i in range(len(x)): > if isinstance(x[i], list): > x[i:i+1] = x[i] > > Thank you all again. If someone could find even a cuter w

Re: str.isspace()

2006-09-03 Thread George Sakkis
Jean-Paul Calderone wrote: > On 3 Sep 2006 09:20:49 -0700, [EMAIL PROTECTED] wrote: > >Are you using the str.isspace() method? I don't use it, so if most > >people don't uses it, then it may be removed from Py 3.0. > > > >I usually need to know if a string contains some non-spaces (not space > >cl

Re: Better way to replace/remove characters in a list of strings.

2006-09-04 Thread George Sakkis
Philipp Pagel wrote: > Chris Brat <[EMAIL PROTECTED]> wrote: > > Is there a better way to replace/remove characters (specifically ' and > > " characters in my case, but it could be anything) in strings in a > > list, than this example to replace 'a' with 'b': > > x = map(lambda foo: foo.replace('a

Re: replace deepest level of nested list

2006-09-04 Thread George Sakkis
David Isaac wrote: > I have a list of lists, N+1 deep. > Like this (for N=2): > [[['r00','g00','b00'],['r01','g01','b01']],[['r10','g10','b10'],['r11','g11' > ,'b11']]] > > I want to efficiently produce the same structure > except that the utlimate lists are replaced by a chosen (by index) item. >

Re: Test for number?

2006-09-04 Thread George Sakkis
Dr. Pastor wrote: > In the following code I would like to ascertain > that x has/is a number. What the simplest TEST should be? > (Could not find good example yet.) > --- > x=raw_input('\nType a number from 1 to 20') > if TEST : > Do_A > else: > Do_B > --- > Thanks for

Re: Test for number?

2006-09-05 Thread George Sakkis
Neil Cerutti wrote: > On 2006-09-04, George Sakkis <[EMAIL PROTECTED]> wrote: > > x=raw_input('\nType a number from 1 to 20') > > try: > > x = int(x) > > if x<1 or x>20: raise ValueError() > > except ValueError: > > D

Re: Better way to replace/remove characters in a list of strings.

2006-09-05 Thread George Sakkis
Chris Brat wrote: > Hi > > Wouldn't this only cause problems with large lists - for once off > scripts with small lists it doesn't seem like a big issue to me. > > Regards, > Chris > > Bruno Desthuilliers wrote: > > Chris Brat a écrit : > > > Thanks, thats exactly what I was looking for - very nea

Re: Refactor a buffered class...

2006-09-06 Thread George Sakkis
Michael Spencer wrote: > Here's a small update to the generator that allows optional handling of the > head > and the tail: > > def chunker(s, chunk_size=3, sentry=".", keep_first = False, keep_last = > False): > buffer=[] > sentry_count = 0 > > for item in s: > buffer.ap

Re: Refactor a buffered class...

2006-09-07 Thread George Sakkis
Michael Spencer wrote: > George Sakkis wrote: > > Michael Spencer wrote: > > > >> Here's a small update to the generator that allows optional handling of > >> the head > >> and the tail: > >> > >> def chunker(s, chun

Re: change property after inheritance

2006-09-07 Thread George Sakkis
Steven Bethard wrote: > David Isaac wrote: > > Le mercredi 06 septembre 2006 16:33, Alan Isaac a écrit : > >>> Suppose a class has properties and I want to change the > >>> setter in a derived class. If the base class is mine, I can do this: > >>> http://www.kylev.com/2004/10/13/fun-with-python-p

Re: Refactor a buffered class...

2006-09-07 Thread George Sakkis
Michael Spencer wrote: > I think the two versions below each give the 'correct' output wrt to the OP's > single test case. I measure chunkerMS2 to be faster than chunkerGS2 across > all > chunk sizes, but this is all about the joins. > > I conclude that chunkerGS's deque beats chunkerMS's list f

Negation in regular expressions

2006-09-07 Thread George Sakkis
It's always striked me as odd that you can express negation of a single character in regexps, but not any more complex expression. Is there a general way around this shortcoming ? Here's an example to illustrate a use case: >>> import re # split with '@' as delimiter >>> [g.group() for g in re.fin

Re: Using Beautiful Soup to entangle bookmarks.html

2006-09-07 Thread George Sakkis
Francach wrote: > Hi, > > I'm trying to use the Beautiful Soup package to parse through the > "bookmarks.html" file which Firefox exports all your bookmarks into. > I've been struggling with the documentation trying to figure out how to > extract all the urls. Has anybody got a couple of longer exa

Re: Using Beautiful Soup to entangle bookmarks.html

2006-09-08 Thread George Sakkis
Francach wrote: > George Sakkis wrote: > > Francach wrote: > > > Hi, > > > > > > I'm trying to use the Beautiful Soup package to parse through the > > > "bookmarks.html" file which Firefox exports all your bookmarks into. > > >

Re: Negation in regular expressions

2006-09-08 Thread George Sakkis
Paddy wrote: > George Sakkis wrote: > > It's always striked me as odd that you can express negation of a single > > character in regexps, but not any more complex expression. Is there a > > general way around this shortcoming ? Here's an example to illustrate a >

Re: Using Beautiful Soup to entangle bookmarks.html

2006-09-08 Thread George Sakkis
Francach wrote: > Hi George, > > Firefox lets you group the bookmarks along with other information into > directories and sub-directories. Firefox uses header tags for this > purpose. I'd like to get this grouping information out aswell. > > Regards, > Martin. Here's what I came up with: http://ra

Re: SQLwaterheadretard3 (Was: Is it just me, or is Sqlite3 goofy?)

2006-09-08 Thread George Sakkis
[EMAIL PROTECTED] wrote: > Sure, errors happen with static typing. After all, the values still > have to match. Dynamic typing allows for more potential errors and, > thanks to Murpy's Law, I will have a much bigger problem with data > integrity. If this was a java or c++ list, all this rant woul

Re: Function metadata (like Java annotations) in Python

2006-09-10 Thread George Sakkis
oripel wrote: > Thanks Paddy - you're showing normal use of function attributes. > They're still hidden when wrapped by an uncooperative decorator. The decorator module may be helpful in defining cooperative decorators: http://www.phyast.pitt.edu/~micheles/python/documentation.html George -- ht

Re: Refactoring Dilemma

2006-09-10 Thread George Sakkis
Kamilche wrote: > ''' > I'm in the middle of a refactoring dilemma. > I have several singletons that I'm turning into modules, for ease of > access. > The usual method is noted as 'Module 1' below. > The new method is noted as 'Module 2'. > Is there any reason NOT to do this that I may be unaware o

Re: Refactoring Dilemma

2006-09-10 Thread George Sakkis
Carl Banks wrote: > Kamilche wrote: > > ''' > > I'm in the middle of a refactoring dilemma. > > I have several singletons that I'm turning into modules, for ease of > > access. > > The usual method is noted as 'Module 1' below. > > The new method is noted as 'Module 2'. > > Is there any reason NOT

Re: CPython keeps on getting faster

2006-09-10 Thread George Sakkis
John Machin wrote: > Here are some data points that illustrate the improvement in speed > since 2.1 for one (probably atypical) application: rummaging through a > 120MB Microsoft Excel spreadsheet file using the xlrd package. > > The time shown is the number of seconds required to open the file an

Re: efficient text file search.

2006-09-11 Thread George Sakkis
noro wrote: > Is there a more efficient method to find a string in a text file then: > > f=file('somefile') > for line in f: > if 'string' in line: > print 'FOUND' > > ? Is this something you want to do only once for a given file ? The replies so far seem to imply so and in this case

Re: Parsing String, Dictionary Lookups, Writing to Database Table

2006-09-11 Thread George Sakkis
Rich Shepard wrote: >I know how I'd do all this in C, but since I'm learning python I have not > found how best to accomplish this despite the books and online references > I've read. Can you post one or more examples of expected input-output pairs ? From your description it's not really clea

Re: Dice gen and analyser script for RPGs: comments sought

2006-09-13 Thread George Sakkis
Richard Buckle wrote: > Comments, insights and overall evaluations are especially welcomed re: > * Cleanliness of design > * Pythonicity of design > * Pythonicity of code > * Efficiency of code > * Quality of docstrings > * Conformance with modern docstring standards > * Conformance with coding st

Re: When is it a pointer (aka reference) - when is it a copy?

2006-09-13 Thread George Sakkis
Grant Edwards wrote: > On 2006-09-13, John Henry <[EMAIL PROTECTED]> wrote: > > So, if I understand you correctly, I must make the reference > > to a more elaborate representation. Like: > > > >i=[1,] > >j=i > >j[0]=2 > >print i > > > > in order to get 2 printed. > > > > Correct?

Re: stock quotes

2006-09-13 Thread George Sakkis
Donlingerfelt wrote: > I would like to download stock quotes from the web, store them, do > calculations and sort the results. However I am fairly new and don't have a > clue how to parse the results of a web page download. I can get to the > site, but do not know how to request the certain data

Re: FtpUtils Progress Bar

2006-09-13 Thread George Sakkis
[EMAIL PROTECTED] wrote: > Hi, > I can successfully upload and download files using Stefan's Schwarzer's > ftputil script. > > The problem is that as some of the files are quite large you cannot see > how much has been downloaded/uploaded. > Even a percentage or just dots going across the screen wo

Re: Algorithm Question

2006-09-14 Thread George Sakkis
Andrew McLean wrote: > Now I want to issue a series of queries, such that when I combine all > the data returned I have accessed all the records in the database. > However, I want to minimise the total number of queries and also want to > keep the number of records returned by more than one query

Re: Algorithm Question

2006-09-14 Thread George Sakkis
Gabriel Genellina wrote: > This is known as a "set cover" algorithm. You have a set of subsets, > and want to determine the smallest set of those subsets, whose union > is the universal set - (uh, what a mess!) I thought of that too, but he seems to be adding a second desired property: the inters

Re: Check if variable is an instance of a File object

2006-09-15 Thread George Sakkis
Bruno Desthuilliers wrote: > [EMAIL PROTECTED] wrote: > > #1 : should I start by checking that 'file' is indeed an instance of a > > File object ? > > Unless you have a *very* compelling reason to do so (and I can't imagine > one here), definitively, no. FWIW, it's pretty common in Python to pass

Re: How do I converted a null (0) terminated string to a Python string?

2006-09-15 Thread George Sakkis
Michael wrote: > Robert, > > Thanks to you and everyone else for the help. The "s.split('\x00', > 1)[0] " solved the problem. And a probably faster version: s[:s.index('\x00')] George -- http://mail.python.org/mailman/listinfo/python-list

Re: Coding Nested Loops

2006-09-15 Thread George Sakkis
Peter Otten wrote: > from itertools import count, izip, cycle, chain, repeat, starmap, imap > from random import choice > > first = ["X", "Y", "Z"] > second = ["A", "B", "C"] > second_count = [13, 14, 33] > third = [1.1, 2.2, 3.3, 4.4] > > random_floats = imap(choice, repeat(third)) > columns = [

Re: something for itertools

2006-09-15 Thread George Sakkis
Daniel Nogradi wrote: > In a recent thread, > http://mail.python.org/pipermail/python-list/2006-September/361512.html, > a couple of very useful and enlightening itertools examples were given > and was wondering if my problem also can be solved in an elegant way > by itertools. > > I have a bunch o

Re: Code Golf Challenge : 1,000 Digits Of Pi

2006-09-18 Thread George Sakkis
Calvin Spealman wrote: > Just once, I would like to see a programming contest that was judged > on the quality of your code, not the number of bytes you managed to > incomprehensively hack it down to. Unfortunately, quality is not as easy to judge as number of bytes. Such contest would be as craz

Re: Curious issue with simple code

2006-09-19 Thread George Sakkis
codefire wrote: > Ah of course, isfile(f) can only return true if it can find f! :) > > I'm going to investigate those other functions too :) > > Thanks a lot guys! > Tony By the way, an easier way to deal with paths is the path.py module (http://www.jorendorff.com/articles/python/path/). Your ex

Re: CONSTRUCT - Adding Functionality to the Overall System

2006-09-19 Thread George Sakkis
Ilias Lazaridis wrote: > I like to add a method "writeDebug(self, msg)" to all (or the most > possible) classes in the system. > > How do I do this? > > * with new style classes > * with old style classes Short answer: you can't do it for builtin or extension types: >>> list.writeDebug = lambda m

Re: value exists (newbie question)

2006-09-19 Thread George Sakkis
eldorado wrote: > Hello, > > I am trying to parse some files so that if a postal code exists, but is > longer than five digits it will return me only the first five digits: > ... > for insDict in insureDict: > insDict['postalcode'] = insDict.get('postalcode')[:5] > ... > This works, except f

Re: new string method in 2.5 (partition)

2006-09-19 Thread George Sakkis
Bruno Desthuilliers wrote: > I must definitively be dumb, but so far I fail to see how it's better > than split and rsplit: I fail to see it too. What's the point of returning the separator since the caller passes it anyway* ? George * unless the separator can be a regex, but I don't think so.

Re: newbe's re question

2006-09-19 Thread George Sakkis
[EMAIL PROTECTED] wrote: > All I am after realy is to change this > > reline = re.line.split('instr', '/d$') If you think this is the only problem in your code, think again; almost every other line has an error or an unpythonic idiom. Have you read any tutorial or sample code before typing this

Re: Using Beautiful Soup to entangle bookmarks.html

2006-09-21 Thread George Sakkis
robin wrote: > "George Sakkis" <[EMAIL PROTECTED]> wrote: > > >Here's what I came up with: > >http://rafb.net/paste/results/G91EAo70.html. Tested only on my > >bookmarks; see if it works for you. > > That URL is dead. Got another? Yeap, try this

Re: returning None instead of value: how to fix?

2006-09-23 Thread George Sakkis
Neil Cerutti wrote: > It's not out of the kindness of our hearts that we help. Heck, I > don't know what it is. Probably I just like reading my own drivel > on the internet and occassionally helping others is a good > excuse. Weird, isn't it ? Good to know that it's not just me that thinks this w

Re: What is the best way to "get" a web page?

2006-09-23 Thread George Sakkis
Pete wrote: > The file "temp.html" is definitely different than the first run, but > still not anything close to www.python.org . Any other suggestions? If you mean that the page looks different in a browser, for one thing you have to download the css files too. Here's the relevant extract from t

Re: A critique of cgi.escape

2006-09-26 Thread George Sakkis
Lawrence D'Oliveiro wrote: > Fredrik Lundh wrote: > > you're not the designer... > > I don't have to be. Whoever the designer was, they had not properly thought > through the uses of this function. That's quite obvious already, to anybody > who works with HTML a lot. So the function is broken and

Re: does anybody earn a living programming in python?

2006-09-26 Thread George Sakkis
Paul Boddie wrote: > One example I read recently [1] described how the marketplace > in Oslo, Norway is currently short of 300-500 Java developers, but if > you look beneath the surface, knowing that there are lots of Java > developers out there looking for work, a gulf between the story and the >

Re: ultra newbie question (don't laugh)

2006-09-26 Thread George Sakkis
John Salerno wrote: > So you see, what I'm asking for is very basic help, sort of along the > lines of "what things do I need to consider before I even begin this?" > Is OOP necessary here? Would utility functions work just as well for > simply writing the information to a file? To start with you

Re: identifying new not inherited methods

2006-09-26 Thread George Sakkis
[EMAIL PROTECTED] wrote: > Hi, > > I am writing a library in which I need to find the names of methods > which are implemented in a class, rather than inherited from another > class. To explain more, and to find if there is another way of doing > it, here is what I want to do: I am defining two cl

Re: identifying new not inherited methods

2006-09-26 Thread George Sakkis
[EMAIL PROTECTED] wrote: > George Sakkis wrote: > [...] > > I'd rather have it as a function, not attached to a specific class: > > > > Thanks a lot George, that was what I was looking for. Got to > understand/appreciate inspect more. > Of course it works as a

Re: iterator question

2006-09-26 Thread George Sakkis
[EMAIL PROTECTED] wrote: > def transform(seq, size): > i = 0 > while i < len(seq): > yield tuple(seq[i:i+size]) > i += size Or for arbitrary iterables, not just sequences: from itertools import islice def transform(iterable, size): it = iter(iterable) while True

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