Re: General questions about embedding Python.

2005-07-03 Thread George Sakkis
on top ? I know very little about embedding python other than it is not considered a pleasant experience, so make sure you look into the alternatives and have very good reasons if you decide to go down this route. George -- http://mail.python.org/mailman/listinfo/python-list

Re: math.nroot [was Re: A brief question.]

2005-07-04 Thread George Sakkis
alid or not. But since a NaN can be thought of as "a flag representing the fact that an error occurred", as you mentioned, it makes sense in practice to ask whether two errors are of the same kind, e.g. for handling them differently. If I understood correctly, your objection is using the equality operator '==' with these semantics for NaNs. I would say that it's a reasonable choice for "practicality beats purity" reasons, if nothing else. George -- http://mail.python.org/mailman/listinfo/python-list

Re: f*cking re module

2005-07-04 Thread George Sakkis
;\n' % g2 text = '''this is a stupid sentence but still I have to write it.''' print regex.sub(replace,text) = Output == print """this is """ a stupid sentence print """ but still I """ have to print """ write it.""" === George -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-04 Thread George Sakkis
) >>> flatten(seq) [1, 2, 3, 4, [5, 6]] And finally for recursive flattening: def flatten(seq): return reduce(_accum, seq, []) def _accum(seq, x): if isinstance(x,list): seq.extend(flatten(x)) else: seq.append(x) return seq >>> flatten(seq) [1, 2, 3, 4, 5, 6] George -- http://mail.python.org/mailman/listinfo/python-list

Re: math.nroot

2005-07-04 Thread George Sakkis
"Mike Meyer" <[EMAIL PROTECTED]> wrote: > "George Sakkis" <[EMAIL PROTECTED]> writes: > > "Steven D'Aprano" <[EMAIL PROTECTED]> wrote: > > > >> But it doesn't make sense to say that two flags are

Re: Existance of of variable

2005-07-04 Thread George Sakkis
ll cases though you should prefer "isinstance(variable, sometype)" instead of "type(variable) == sometype", so that it doesn't break for subclasses of sometype. > Thanks for your help! > > -- Josiah Regards, George -- http://mail.python.org/mailman/listinfo/python-list

Re: distutils is able to handle...

2005-07-05 Thread George Sakkis
your case. I would suggest SCons (http://www.scons.org/), a modern make/automake/autoconf replacement that uses python for its configuration files instead of yet another cryptic half-baked mini-language or XML. George -- http://mail.python.org/mailman/listinfo/python-list

Re: what is __init__.py used for?

2005-07-05 Thread George Sakkis
;ll get a NameError exception: >>> import breakfast.spam as spam >>> breakfast.spam NameError: name 'breakfast' is not defined In either form of import though, the __init__.py has to be in the breakfast directory. HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: f*cking re module

2005-07-05 Thread George Sakkis
re posting anything you may regret later, but this doesn't mean you should leave this group; as you saw already, it's far more tolerant and civilized than other groups in this respect. > But thank you for all your help about the re module, > > Noud Aldenhoven Cheers, George -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Regular Expressions: re.sub(regex, replacement, subject)

2005-07-05 Thread George Sakkis
ion that doesn't require writing a replacement function: backreferences. Replacement can be a string where \1 denotes the first group of the match, \2 the second and so on. Continuing the example, you could hide the dates by: >>> rx.sub(r'\1 in ', 'I was hired in 2001

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-05 Thread George Sakkis
act by: from itertools import imap def flatten(iterable): if not hasattr(iterable, '__iter__'): return [iterable] return sum(imap(flatten,iterable),[]) George -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-05 Thread George Sakkis
beats purity IMO). In any case, python was never about minimizing keystrokes; theres another language that strives for this . So, who would object the full-word versions for python 3K ? def -> define del -> delete exec -> execute elif -> else if George -- http://mail.python.org/mailman/listinfo/python-list

Re: map/filter/reduce/lambda opinions and background unscientificmini-survey

2005-07-06 Thread George Sakkis
"Terry Reedy" <[EMAIL PROTECTED]> wrote: > "George Sakkis" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Still it's hard to explain why four specific python keywords - def, > > del, exec and elif - were chosen to be abbr

Re: frozenset question

2005-07-06 Thread George Sakkis
a set and don't add sets as keys in dictionaries, you currently have a choice; both frozenset and set will work. So all other things being equal, it makes sense to ask about the relative performance if the only 'evil' it may introduce can be rectified in a single import. George -- http://mail.python.org/mailman/listinfo/python-list

Re: frozenset question

2005-07-06 Thread George Sakkis
"Steven D'Aprano" <[EMAIL PROTECTED]> wrote: > On Wed, 06 Jul 2005 10:15:31 -0700, George Sakkis wrote: > > > Well, they *may* be interchangable under some conditions, and that was > > the OP's point you apparently missed. > > I didn't m

Re: Use cases for del

2005-07-06 Thread George Sakkis
t; > But what's wrong with properties? > > Huh? I guess he means why not define foo as property: class demo(object): foo = property(fget = lambda self: self.v, fset = lambda self,v: setattr(self,'v',v)) d = demo() d.foo = 3 print d.foo George -- http://mail.python.org/mailman/listinfo/python-list

Re: Thoughts on Guido's ITC audio interview

2005-07-07 Thread George Sakkis
ish on Windows ? At best this may say something about the difference in perfomance between the two JREs (assuming that most Windows and Mac users of Eclipse have similar experience with yours). George -- http://mail.python.org/mailman/listinfo/python-list

Re: Use cases for del

2005-07-07 Thread George Sakkis
"Grant Edwards" <[EMAIL PROTECTED]> wrote: > On 2005-07-07, George Sakkis <[EMAIL PROTECTED]> wrote: > > > I guess he means why not define foo as property: > > > > class demo(object): > > foo = property(fget = lambda self: self.v, > >

Re: Thoughts on Guido's ITC audio interview

2005-07-07 Thread George Sakkis
X in platform Y is Sun's JVM in Y" is kinda misleading. Disclaimer: I am neither Java's not Eclipse's advocate; I'll choose python over Java any day, but let's put the blame where it is due. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there an easy way to get at the value of DBL_MAX from Python?

2005-07-07 Thread George Sakkis
stants, but it seems it has been excluded from the latest (and final I believe) version of Numeric (24.0b2) that I have installed, so I can't actually check it. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Is there an easy way to get at the value of DBL_MAX from Python?

2005-07-07 Thread George Sakkis
"George Sakkis" <[EMAIL PROTECTED]> wrote: > Where exactly have you been looking ? I guess not in Google, because > the fifth result after querying "dbl_max" is > http://mail.python.org/pipermail/pythonmac-sig/2002-July/005916.html, > which follows up

Re: Use cases for del

2005-07-08 Thread George Sakkis
4 > Anyway, time to call it a night so tomorrow I don't make anymore silly > mistakes on comp.lang.python. :) That would be a great idea ;-) An even greater idea would be to give up on this "None should mean undefined" babble; it looks like a solution looking for a

Re: f*cking re module

2005-07-08 Thread George Sakkis
o runtime errors (at least for anyone that has been using python for a week or more), so even if the syntax checker did report all of them at once it wouldn't make much difference in the overall debugging time. Third, at least one editor (Komodo) reports syntax error on the fly as you edit and t

Re: map/filter/reduce/lambda opinions and background unscientific mini-survey

2005-07-08 Thread George Sakkis
y among builtin data structures, not overwhelmingly more useful than set or dict comprehensions), but there's a long way till that day. George -- http://mail.python.org/mailman/listinfo/python-list

Re: python nested class

2005-07-08 Thread George Sakkis
# respective outer instance if and only if the # attribute is already defined in the outer instance if hasattr(outer, attr): setattr(outer,attr,value) else: super(this.__class__,this).__setattr__(attr,

Re: Python Module Exposure

2005-07-09 Thread George Sakkis
s for ISet's so that a client can use either or them transparently. - Add an ISet.remove() for removing elements, Intervals, ISets as complementary to ISet.append(). - More generally, think about mutable vs immutable Intervals and ISets. The sets module in the standard library will give you

Re: Python Module Exposure

2005-07-09 Thread George Sakkis
"Jacob Page" <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > 1. As already noted, ISet is not really descriptive of what the class > > does. How about RangeSet ? It's not that long and I find it pretty > > descriptive. In this case, it would be a go

Re: removing list comprehensions in Python 3.0

2005-07-09 Thread George Sakkis
ore than once. > > Raymond Hettinger Similar arguments can be given for dict comprehensions as well. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Module Exposure

2005-07-09 Thread George Sakkis
"Jacob Page" <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > There are several possible use cases where dealing directly with > > intervals would be appropriate or necessary, so it's good to have them > > supported directly by the module. > >

Re: Python Module Exposure

2005-07-09 Thread George Sakkis
"Jacob Page" <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > As I see it, there are two main options you have: > > > > 1. Keep Intervals immutable and pass all the responsibility of > > combining them to IntervalSet. In this case Interval.__ad

Re: Python Module Exposure

2005-07-10 Thread George Sakkis
| [3,7] = (2,7] but (2,4] | [5,7] = { (2,4], [5,7] } That is, the set of intervals is not closed under union. OTOH, the set of intervals _is_ closed under intersection; intersecting two non-overlapping intervals gives the empty interval. George -- http://mail.python.org/mailman/listinfo/python-list

Re: passing arguments to a function - do I need type ?

2005-07-10 Thread George Sakkis
a function, not method. Also, the pythonic way of writing it (since 2.4) is: from math import sqrt from itertools import izip def distance(sequence1, sequence2): return sqrt(sum((x-y)**2 for x,y in izip(sequence1, sequence2))) > Thank you very much for your help. > > Phil Regards, George -- http://mail.python.org/mailman/listinfo/python-list

Read-only class properties

2005-07-10 Thread George Sakkis
nction(objtype) def __set__(self, obj, value): raise AttributeError, "can't set class attribute" return Descriptor() Accessing Foo.TheAnswer works as expected, however __set__ is apparently not called because no exception is thrown when setting Foo.TheAnswer.

Re: Python Module Exposure

2005-07-10 Thread George Sakkis
re.search() and they expose a set of useful methods (group(), groups(), etc.). However if the user attempts to create a Match instance, a TypeError is raised. Currently I like this option better; it's both user and developer friendly :) George -- http://mail.python.org/mailman/listinfo/python-list

Re: decorators as generalized pre-binding hooks

2005-07-10 Thread George Sakkis
substantially annoying and error-prone. I'm not sure what you mean here; where is the 'triple typing' ? And how is this an argument against class decorators ? George -- http://mail.python.org/mailman/listinfo/python-list

Re: Access descendant class's module namespace from superclass

2005-07-11 Thread George Sakkis
at seems kind > of awkward.) > > Is this possible using Python 2.3? Any better ways to accomplish this? I don't know if it's "better", but since you know that self.__module__ has already been imported, you can access it through the sys.modules dict: a = sys.module

Re: automatically assigning names to indexes

2005-07-12 Thread George Sakkis
should happen for vectors of size != 3 ? I don't think that a general purpose vector class should allow it; a Vector3D subclass would be more natural for this. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Search & Replace with RegEx

2005-07-12 Thread George Sakkis
x = re.compile(r'^abs:.*\\(.+)$') input = FileInput(filename) unparsed = [] for line in input: try: print regex.match(line).group(1) except: unparsed.append(input.filelineno()) print line print "Unparsed lines:", ','.join(map(str,unparsed)) George -- http://mail.python.org/mailman/listinfo/python-list

Re: automatically assigning names to indexes

2005-07-12 Thread George Sakkis
, so I don't see how this can be generalized _usefully_ to arbitrary number of dimensions. George -- http://mail.python.org/mailman/listinfo/python-list

Re: How to match literal backslashes read from a text file using regular expressions?

2005-07-12 Thread George Sakkis
rint "matched:", match.group(1) else: print "did not match" #= output === line 1 matched: 'di_--v*-.ga_-t line 2 matched: 'pas-*m # George -- http://mail.python.org/mailman/listinfo/python-list

Re: all possible combinations

2005-07-13 Thread George Sakkis
t: def iterPermutations(num, seq): if num: for rest in iterPermutations(num-1, seq): for item in seq: yield rest + [item] else: yield [] for comb in iterPermutations(4, list("abc")): print ''.join(comb) George -- http://mail.python.org/mailman/listinfo/python-list

Re: Consecutive Character Sequences

2005-07-13 Thread George Sakkis
pby: import itertools as it def hasConsequent(aString, minConsequent): for _,group in it.groupby(aString): if len(list(group)) >= minConsequent: return True return False George -- http://mail.python.org/mailman/listinfo/python-list

Re: Consecutive Character Sequences

2005-07-14 Thread George Sakkis
"Aries Sun" <[EMAIL PROTECTED]> wrote: > I have tested George's solutions, it seems not complete. When pass (s, > 3) to the function hasConsequent(), it returns the wrong result. What are you talking about ? I get the correct answer for >>> hasConsequent(&

Re: Consecutive Character Sequences

2005-07-14 Thread George Sakkis
"Aries Sun" <[EMAIL PROTECTED]> wrote: > Hi George, > I used Python 2.4.1, the following are the command lines. > But the reslut was still False. Is there anything wrong with below > codes?hasConsequent("taaypiqee88adbbba", 3) All indentation was lost in you

Re: all possible combinations

2005-07-14 Thread George Sakkis
of 'abc' and when it ends get back to us, or rather our grand-grandchildren. In the meantime, learn about recursion, generators and accumulating loops and try to understand the right, efficient solutions already posted. Cynically yrs, George PS: Btw, using ALL_CAPITALS (at least for local variables) is BAD STYLE; the same holds for variables named 'list' and 'string', independent of case. -- http://mail.python.org/mailman/listinfo/python-list

Re: eBay.py - Has anyone looked at this???

2005-07-14 Thread George Sakkis
earth is Session and the other attributes coming from. From a brief look, the api seems like a quick & dirty solution that would benefit from refactoring, so you'd rather not try to learn python from it. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question: Explain this behavior

2005-07-14 Thread George Sakkis
640) uses the prime number computation you posted, so read it again if it's not clear what the "else" clause does with loops. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Programming Contest

2005-07-16 Thread George Sakkis
t that doesn't mean there aren't any. Hints: - You have to take exactly one decision (flight or stop) every single day until you reach the destination; no more, no less. - There is no time machine; days pass in one direction only, one at a time. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Programming Contest

2005-07-16 Thread George Sakkis
me. So any heavy preprocessing on the schedule is rather unlikely to pay off. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Filtering out non-readable characters

2005-07-16 Thread George Sakkis
string.maketrans('','') >>> unprintable = identity.translate(identity, string.printable) George -- http://mail.python.org/mailman/listinfo/python-list

Re: Filtering out non-readable characters

2005-07-16 Thread George Sakkis
"Peter Hansen" <[EMAIL PROTECTED]> wrote: > Jp Calderone wrote: > > On Sat, 16 Jul 2005 19:01:50 -0400, Peter Hansen <[EMAIL PROTECTED]> wrote: > >> George Sakkis wrote: > >>>>>> identity = string.maketrans('','&#x

Re: Filtering out non-readable characters

2005-07-16 Thread George Sakkis
"Peter Hansen" <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > "Peter Hansen" <[EMAIL PROTECTED]> wrote: > >>>> Where did you learn that, George? > > > > Actually I first read about this in the Cookbook; the

Re: Python to C++ translation?

2005-07-18 Thread George Sakkis
f, x): self.x = x class A(X): def methodA(): pass # Ignore the details class B(X): def methodB(): pass # Ignore the details class C: def __init__(self, x1, x2): self.x1 = x1 self.x2 = x2 So the constructor of C would take two X instan

Re: goto

2005-07-19 Thread George Sakkis
alls as profitable > as these obviously ignorant companies? It should not really come as a shock that the same fellow who came up with a brilliant efficient way to generate all permutations (http://tinyurl.com/dnazs) is also in favor of goto. Coming next from rbt: "Pointer arithmetic in python ?". George -- http://mail.python.org/mailman/listinfo/python-list

Re: getting the class name of a subclass

2005-07-20 Thread George Sakkis
function but in my real life code i already > have several params shipped to the init so i wanted to solve it slightly > more elegant. > > Regards, > Benedict Make printclass a class method: class A(object): def __init__(self): print "I'm A" # for

RE: Listing Processes Running on Remote Machines

2005-07-21 Thread George Flaherty
Look into STAF http://staf.sourceforge.net/index.php -g -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of yoda Sent: Thursday, July 21, 2005 9:23 AM To: python-list@python.org Subject: Listing Processes Running on Remote Machines Hello Hackers, I'm develop

Re: Returning histogram-like data for items in a list

2005-07-21 Thread George Sakkis
() > > Jeethu Rao The performance penalty of the exception is imposed only the first time a distinct item is found. So unless you have a huge list of distinct items, I seriously doubt that this is faster at any measurable rate. George -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP on path module for standard library

2005-07-22 Thread George Sakkis
ion is a valid point for debate, so the PEP should definitely address it. IMO os.path and most (if not all) other equivalent modules and functions should be deprecated, though still working until 2.9 for backwards compatibility, and dropped for python 3K. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Returning histogram-like data for items in a list

2005-07-22 Thread George Sakkis
.groupby(sorted(L1))] Or if you care about performance rather than number of lines, use this: def hist(seq): h = {} for i in seq: try: h[i] += 1 except KeyError: h[i] = 1 return h.items() George -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP on path module for standard library

2005-07-22 Thread George Sakkis
are we going to maintain both alternatives forever? (And what about > > all the duplication with the os module itself, like the cwd() > > constructor?) Remember TOOWTDI. > > """ > > Read literally, this says (at least to me) "I don't want to fix it be

Re: PEP on path module for standard library

2005-07-22 Thread George Sakkis
common cases. It's a tradeoff, so arguments for both cases should be discussed. George -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP on path module for standard library

2005-07-22 Thread George Sakkis
many (or most) common cases. It's a tradeoff, so arguments for both cases should be discussed. George -- http://mail.python.org/mailman/listinfo/python-list

Re: PEP on path module for standard library

2005-07-22 Thread George Sakkis
"Andrew Dalke" <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > You're right, conceptually a path > > HAS_A string description, not IS_A string, so from a pure OO point of > > view, it should not inherit string. > > How did you decide it&#

Re: Something that Perl can do that Python can't?

2005-07-22 Thread George Sakkis
> if not line: > break > print 'LINE:', line, > > If anyone can do it the more Pythonic way with some sort of iteration > over stdout, please let me know. > > Jeff You can use the sentinel form of iter(): for line in iter(stdout.readline, '&

Re: PEP on path module for standard library

2005-07-23 Thread George Sakkis
tion, one of them woud be more natural choice than the other. > I trust my intuition on this, I just don't know how to justify it, or > correct it if I'm wrong. My intuition also happens to support subclassing string, but for practical reasons rather than conceptual. George -- http://mail.python.org/mailman/listinfo/python-list

Re: Lists & "pointers"

2005-07-23 Thread George Sakkis
, blah.. }) And this would be equivalent to shallow copy. Whether you need a deep copy depends on what each "blah" is. More specifically it depends on whether the values of the dictionary are mutable or not (the keys are known to be immutable anyway). If they are immutable, a shallow copy is enough. If not, check whether all dictionaries refer to the same values or separate copies of the values. Only in the latter case you need deep copy. HTH, George -- http://mail.python.org/mailman/listinfo/python-list

RE: Emacs skeletons

2005-07-26 Thread George Flaherty
Michael, Since you are on this topic, do you (or anyone else) have any type of "code-completion" mode for python in emacs? Thanks -george -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Hoffman Sent: Tuesday, July 26, 2005 1:36 PM

RE: Emacs skeletons

2005-07-26 Thread George Flaherty
Yeah I have used tags with java and c before and they are very nice. Its just that, I have been trying to find something similar to JDE/PythonWinEditor code completion for an emacs-python mode. I will keep trying and thanks for the input. -george -Original Message- From: [EMAIL

Re: namespaces

2005-07-31 Thread George Sakkis
able=string.maketrans(badcars, replaceChar*len(badcars)) def translate(text): return text.translate(table) # bind any attributes you want to be accessible # translate.badcars = badcars # ... return translate tr = translateFactory() tr("Hel\xfflo") George -- http://mail.python.org/mailman/listinfo/python-list

Re: namespaces

2005-08-01 Thread George Sakkis
Paolino wrote: > >>Even worse I get with methods and function namespaces. > > > > What is "even worse" about them? > > > For my thinking, worse is to understand how they derive their pattern > from generic namespaces. > Methods seems not to have a wr

Re: Getting not derived members of a class

2005-08-01 Thread George Sakkis
this is the case, check the following valid (though highly discouraged) example: class X: def __init__(self, x): if isinstance(x,str): self._s = x else: self._n = x x1 = X("1") x2 = X(1) dir(x1) ['__doc__', '__init__', '__module__', '_s'] dir(x2) ['__doc__', '__init__', '__module__', '_n'] George -- http://mail.python.org/mailman/listinfo/python-list

Re: Getting not derived members of a class

2005-08-01 Thread George Sakkis
ss class Y1(X): pass class Y2(X): pass class Z(Y1,Y2): pass >>> z = Z() >>> z.__class__.__mro__ (, , , , ) Old style classes don't have __mro__, so you have to write it yourself; in any case, writing old style classes in new code is discouraged. George --

RE: Documentation

2005-08-10 Thread George Flaherty
I prefer epydoc http://epydoc.sourceforge.net. Granted it is an add on and uses "LaTex'ish" flags in the comments, but the final doc is very clean. -g -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jan Danielsson Sent: Wednesday, August 10, 2005 11:18

Re: Help sorting a list by file extension

2005-08-11 Thread George Yoshida
argument to sorted will make it simpler:: >>> sorted(namelist, key=lambda x:int(x.rsplit('.')[-1])) -- george -- http://mail.python.org/mailman/listinfo/python-list

Re: fully-qualified namespaces?

2005-09-12 Thread George Sakkis
he (optional) renaming of the imported modules/classes I would guess: # Hippo.py import Crypto as PythonCrypto class Crypto: pass h1 = PythonCrypto.Hash h2 = Crypto.Hash# refers to Hippo.Crypto HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: Simplifying imports?

2005-09-13 Thread George Sakkis
e.f_globals, caller_locals, [name]) # extract 'C' from 'A.B.C' attribute = name[name.rfind('.')+1:] if hasattr(module,attribute): caller_locals[attribute] = getattr(module,attribute) #== Or even better, forget about the braindead java restriction of one class per file and organize your code as it makes more sense to you. HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: Simplifying imports?

2005-09-13 Thread George Sakkis
"Terry Hancock" <[EMAIL PROTECTED]> wrote: > On Tuesday 13 September 2005 12:46 pm, George Sakkis wrote: > > Or even better, forget about the braindead java restriction of one > > class per file and organize your code as it makes more sense to you. > > W

Re: Python Doc Problem Example: os.path.split

2005-09-18 Thread George Sakkis
Another epileptic seizure on the keyboard. Apart from clue deficit disorder, this guy seems to suffer from some serious anger management problems...*plonk* "Xah Lee" <[EMAIL PROTECTED]> wrote: > Python Doc Problem Example > > Quote from: > http://docs.python.org/lib/module-os.path.html >

Re: Creating a list of Mondays for a year

2005-09-18 Thread George Sakkis
#x27;2/7/2005', ... ] Get the dateutil package (https://moin.conectiva.com.br/DateUtil): import dateutil.rrule as rrule from datetime import date mondays2005 = tuple(rrule.rrule(rrule.WEEKLY, dtstart=date(2005,1,1), count=52,

Re: How am I doing?

2005-09-18 Thread George Sakkis
t;) > a.addScore(newScore,name) > a.showScores() > continue "continue" doesn't do anything at the line you put it. When do you want your program to exit ? As it is, it will loop forever. > Anything I could have done differently or any "bad-habits" you think I > have which could lead to ultimate doom I really appreciate to know. > > TIA HTH, George -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a list of Mondays for a year

2005-09-18 Thread George Sakkis
"Peter Hansen" <[EMAIL PROTECTED]> wrote: > George Sakkis wrote: > > "Chris" <[EMAIL PROTECTED]> wrote: > >>Is there a way to make python create a list of Mondays for a given year? > > > > Get the dateutil package (https://moin.cone

Re: How to write this iterator?

2005-09-19 Thread George Sakkis
x27;d', 'e', 'a', 'b'] >>> list(islice(cyclefrom('abcde', 5), 9)) ['a', 'b', 'c', 'd', 'e', 'a', 'b', 'c', 'd'] """ # chain the last part with the first one and cycle over it. Needs # to replicate the iterable for consuming each part it1,it2 = tee(iterable) return cycle(chain(islice(it1, start, None), islice(it2, start))) By the way, these generators seem general enough to make it to itertools. Actually cyclefrom can be accomodated by adding the optional start argument to itertools.cycle. What do you think ? George -- http://mail.python.org/mailman/listinfo/python-list

Re: How to write this iterator?

2005-09-20 Thread George Sakkis
"Jordan Rastrick" <[EMAIL PROTECTED]> wrote: > I've written this kind of iterator before, using collections.deque, > which personally I find a little more elegant than the list based > approach: Nice, that's *much* more elegant and simple ! Here's the class-based version with append; note that i

Re: Chronological Processing of Files

2005-09-21 Thread George Sakkis
(), **sort_kwds) # sort files by directory sorted_by_dir = sorted(top.files(), **sort_kwds) \ + sum((sorted(dir.files(), **sort_kwds) for dir in path(top).walkdirs()), []) George -- http://mail.python.org/mailman/listinfo/python-list

Re: Intermediate to expert book

2005-09-21 Thread George Sakkis
t? If you would give a chance to a task-oriented intermediate to advanced book, check the second edition of the python cookbook. It has over 200 practical recipes, covers 2.3 and 2.4 and has taken excellent reviews. George -- http://mail.python.org/mailman/listinfo/python-list

Re: interactive execution

2005-02-08 Thread George Yoshida
e IDLE do. exec statement in name_space will do the trick. >>> d = {} >>> exec 'foo=555' in d >>> d['foo'] 555 >>> exec "print foo" in d 555 - george -- http://mail.python.org/mailman/listinfo/python-list

Re: Name of type of object

2005-02-09 Thread George Sakkis
d-style classes like exceptions: > > py> e = NameError("global name 'foo' is not defined") > py> type(e) > > py> type(e).__name__ > 'instance' > > For old-style classes, you'll need to go through __class__ > > py> e.__class__ > > py> e.__class__.__name__ > 'NameError' > > STeVe To sum up: def typename(obj): try: return obj.__class__.__name__ except AttributeError: return type(obj).__name__ George -- http://mail.python.org/mailman/listinfo/python-list

Re: check if object is number

2005-02-11 Thread George Sakkis
ly not, integers and floats typically are; on the other hand, complex numbers are usually not expected, even though mathematically they are 'numeric'. In this case, you can write something like: def isNumeric(obj): # consider only ints and floats numeric return isinstance(obj

Re: check if object is number

2005-02-11 Thread George Sakkis
False > > Michael > > -- > Michael D. Hartl, Ph.D. > Chief Technology Officer > http://quarksports.com/ > Huh ? What python version has this ? Surely not 2.3 and 2.4. George -- http://mail.python.org/mailman/listinfo/python-list

Re: check if object is number

2005-02-11 Thread George Sakkis
> George Sakkis wrote: > > "Steven Bethard" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > >>Is there a good way to determine if an object is a numeric type? > > > > In your example, what does your application consid

Re: check if object is number

2005-02-12 Thread George Sakkis
ay comparison works as of now is error-prone, to say the least. Comparing ints with strings is no more valid than adding them, and python (correctly) raises TypeError for the latter, but not for the former. For the record, here's the arbitrary and undocumented (?) order among some main builtin types: >>> None < 0 == 0.0 < {} < [] < "" < () True George -- http://mail.python.org/mailman/listinfo/python-list

Re: Python in EDA

2005-02-12 Thread George Sakkis
ed in knowing if such efforts are on. Apart from that > also any input on EDA softwares using Python will be useful. > > regards, > Vishal > GIYF (Google Is Your Friend): http://www-cad.eecs.berkeley.edu/~pinhong/scriptEDA/ Regards, George -- http://mail.python.org/mailman/listinfo/python-list

Re: builtin functions for and and or?

2005-02-13 Thread George Sakkis
.next() except StopIteration: return False else: return True def all(pred, iterable): try: dropwhile(pred,iterable).next() except StopIteration: return True else: return False George -- http://mail.python.org/mailman/listinfo/python-list

Re: Distutils: relative paths

2005-02-19 Thread George Sakkis
s are expected to be part of the package in the source directories" means that you cannot specify a sibling directory as package data, so the easiest way is to make "schemas" child of foo. If this is not possible, you may check the 'data_files' option (http://www.python.org/doc/current/dist/node12.html). George -- http://mail.python.org/mailman/listinfo/python-list

Re: [ANN] Python 2.4 Quick Reference available

2005-02-19 Thread George Sakkis
pe testing > (for example, writing "isinstance(f, file)"). > """ > > ... which more accurately reflects what I believe the consensus is > about the usage of open vs. file. > > -- > |>|\/|< > /--\ > |David M. Cooke > |cookedm(at)physics(dot)mcmaste

Re: How Do I get Know What Attributes/Functions In A Class?

2005-02-20 Thread George Sakkis
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Thank you Hans. Could you give me a simple sample of using inspect? > http://www.python.org/doc/current/lib/module-inspect.html George -- http://mail.python.org/mailman/listinfo/python-list

Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-21 Thread George Sakkis
ost] The Essence is irrelevant. - - - All your thread are belong to us. - - - George -- http://mail.python.org/mailman/listinfo/python-list

Re: [EVALUATION] - E02 - Support for MinGW Open Source Compiler

2005-02-23 Thread George Sakkis
u jump? > > jump: > > [EVALUATION] - E02 - Support for MinGW Open Source Compiler > Essence: > http://groups-beta.google.com/group/comp.lang.python/msg/5ba2a0ba55d4c102 Lol, this guy is hopeless :-) George -- http://mail.python.org/mailman/listinfo/python-list

Re: survey

2005-03-04 Thread George Sakkis
Dave After a little googling, that's what I found: http://citeseer.nj.nec.com/article/prechelt00empirical.html http://www.sensi.org/~ak/impit/studies/report.pdf George -- http://mail.python.org/mailman/listinfo/python-list

Re: Integer From A Float List?!?

2005-03-04 Thread George Sakkis
think). > > And, finally, when doing scientific stuff, I found IPython > (http://ipython.scipy.org/) to be an invaluable tool. It's a much > improved Python interpreter. > > Peace > Bill Mill > bill.mill at gmail.com Using numpy, your example would be: >>> from Numeric import array >>> matrix = array([1.5, 4.3, 5.5]) >>> integer_matrix = matrix.astype(int) George -- http://mail.python.org/mailman/listinfo/python-list

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