Re: Double underscores -- ugly?

2008-02-19 Thread Marco Mariani
Ben Finney wrote: I realise that double underscores make the language conceptually cleaner in many ways (because fancy syntax and operator overloading are just handled by methods), but they don't *look* nice. That's a good thing, in that it draws attention to the names. Well, double

Re: The big shots

2008-02-20 Thread Marco Mariani
Sergio Correia wrote: I don't get this thread. At all. I want my 15 minutes back. I think it's a sort of Turing test, to fine-tune some spammer's text generating algorithm. -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a file with $SIZE

2008-03-12 Thread Marco Mariani
Robert Bossy wrote: Indeed! Maybe the best choice for chunksize would be the file's buffer size... I won't search the doc how to get the file's buffer size because I'm too cool to use that function and prefer the seek() option since it's lighning fast regardless the size of the file and it

Re: [OT] troll poll

2008-04-01 Thread Marco Mariani
Daniel Fetchinson wrote: This is a quick poll to have scientific data on our beloved troll community: Whose trolling behaviour is more professional? (check one) You forgot to mention Ilias Lazaridis. He needs to be Analyzed and Evaluated, too. --

Re: splitting an XML file on the basis on basis of XML tags

2008-04-03 Thread Marco Mariani
Steve Holden wrote: the XML file is almost a TB in size... Good grief. When will people stop abusing XML this way? Not before somebody writes a clever xmlfs for the linux kernel :-/ -- http://mail.python.org/mailman/listinfo/python-list

Re: splitting an XML file on the basis on basis of XML tags

2008-04-03 Thread Marco Mariani
Marco Mariani wrote: the XML file is almost a TB in size... Good grief. When will people stop abusing XML this way? Not before somebody writes a clever xmlfs for the linux kernel :-/ Ok. I meant it as a joke, but somebody has been there and done that. Twice. http://xmlfs.modry.cz

Re: who said python can't be obsfucated!?

2008-04-03 Thread Marco Mariani
Bruno Desthuilliers wrote: sig=lambda m:'@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in m.split('@')]) Pff... you call that a quicksort? From http://www.p-nand-q.com/python/obfuscated_python.html import sys funcs = range(10) def A(_,o): _[3]=_[5]() def B(_,o):

Re: who said python can't be obsfucated!?

2008-04-03 Thread Marco Mariani
Bruno Desthuilliers wrote: sig=lambda m:'@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in m.split('@')]) Pff... you call that a quicksort? From http://www.p-nand-q.com/python/obfuscated_python.html import sys funcs = range(10) def A(_,o): _[3]=_[5]() def B(_,o):

Re: who said python can't be obsfucated!?

2008-04-03 Thread Marco Mariani
Bruno Desthuilliers wrote: Pff... you call that a quicksort? Nope, only somewhat obfuscated Python. And it seems it's at least obfuscated enough for you to believe it could be a quicksort implementation !-) You're right, but I'm past the quine age and don't bother parsing obfuscated code

Re: object-relational mappers

2008-04-03 Thread Marco Mariani
Tim Golden wrote: I've recently used Elixir and found it very useful for a small-scale database with no more than a dozen tables, well-structured and easily understood. I'd certainly use it again for anything like that to save me writing what would amount to boilerplate SQL. But I'd hate to

Re: object-relational mappers

2008-04-03 Thread Marco Mariani
Bruno Desthuilliers wrote: A simple select query would be db.select('customers') or db.select('customers', name='John'). But you can also resort to plain sql as follows: db.query('select * from customers where name = John'). Simple, effective and doesn't get in your way. Seems nice too

Re: Java or C++?

2008-04-14 Thread Marco Mariani
[EMAIL PROTECTED] wrote: Which one do you think will educate me the best? Advanced javascript might teach you something too, and be very useful at the same time. Take a look at the Crockford lessons on Yahoo! Video. http://video.yahoo.com/watch/111593 http://video.yahoo.com/watch/111594

Re: 答复: Java or C++?

2008-04-14 Thread Marco Mariani
Penny Y. wrote: Javascript is different from Java at all. I think even rocks know that. Yet, some use of closure and prototype-based inheritance might be interesting to the OP. Why not Perl? Come on, learning Perl after two years of Python? How harsh. Perl is a functional language, And

Re: py3k s***s

2008-04-16 Thread Marco Mariani
Aaron Watters wrote: stuff out there you can get so easily -- all the stuff that py3k will break -- most of which won't get ported -- and if it does can we be sure it will be tested properly? No, probably you will end up beta testing someone's quick port of what used to be rock solid

Re: I just killed GIL!!!

2008-04-17 Thread Marco Mariani
Torsten Bronger wrote: If I were you I would keep it a secret until a Hollywood producer offers big bucks for the film rights. Who would play Guido, I wonder? Ralf Möller. No other. And the GIL killer? Clive Owen, Matt Damon, Mark Wahlberg? --

Re: Can't do a multiline assignment!

2008-04-17 Thread Marco Mariani
[EMAIL PROTECTED] wrote: Yes, it makes it more readable. And yes, it does make it (a lot) more maintainable. Mainly because I don't have those four variables, I have about thirty. And I think I won't need to one or two of them, but maybe all of them at once. have fun with locals(), then (but

Re: Python Success stories

2008-04-22 Thread Marco Mariani
azrael wrote: Please give me any arguments to cut him down about his commnets like :keep programing i python. maybe, one day, you will be able to program in VisualBasic This hurts. Please give me informations about realy famous aplications. He's joking. Perl is a dysfunctional language and

Re: Zope/DTML Infuriating...

2008-04-29 Thread Marco Mariani
Jens wrote: I've the checked that i'm referring to the variables correctly, so the only explanation i can come up with, is that '+' doesn't result in a string concatenation (with implicit typecast to string of the integer variable(this is a interpreted language after all)). No, sorry. You

Re: Zope/DTML Infuriating...

2008-04-29 Thread Marco Mariani
Jens wrote: You might have wrong assumptions from previous PHP experiences. 'x'+4 Traceback (most recent call last): File stdin, line 1, in module TypeError: cannot concatenate 'str' and 'int' objects ... and the non snobby answer would have been: ... dtml-var expr=_['prefix'] +

Re: Zope/DTML Infuriating...

2008-04-29 Thread Marco Mariani
Jens wrote: Hey no worriest. Is this the tutorial you're referring to: http://docs.python.org/lib/typesmapping.html Is there anything better? That's the library reference - the one to keep under the pillow. It also documents the core -- i.e. builtin objects. As for the language semantics,

Re: computing with characters

2008-04-30 Thread Marco Mariani
Torsten Bronger wrote: However, join() is really bizarre. The list rather than the separator should be the leading actor. No, because join must work with _any sequence_, and there is no sequence type to put the join method on. This semantic certainly sets python apart from many other

Re: Decimal vs Float comparasion

2008-05-06 Thread Marco Mariani
Gasto wrote: I still don't see why such a module exists. There are 2.0 types of programmers: those who always use floating point, and those who know how to use them. -- http://mail.python.org/mailman/listinfo/python-list

Re: parameters to lambda's executed at run time.

2008-05-06 Thread Marco Mariani
Boris Borcic wrote: One way : from functools import partial def func(item) : print item llist = [partial(func,item) for item in range(5)] for thing in llist : thing() 0 1 2 3 4 Another way: class Func(object): def __init__(self, item): self.item = item def

Re: sed to python: replace Q

2008-05-06 Thread Marco Mariani
Raymond wrote: Aren't sed, awk, grep, and perl the reference implementations of search and replace? I don't know about reference implementations, but I daresay they are a mess w.r.t. usability. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why don't generators execute until first yield?

2008-05-07 Thread Marco Mariani
Duncan Booth wrote: It does this: @greedy def getCommandsFromUser(): while True: yield raw_input('Command?') for cmd in getCommandsFromUser(): print that was command, cmd Command?hello Command?goodbye that was command hello

Re: Why don't generators execute until first yield?

2008-05-07 Thread Marco Mariani
Marco Mariani wrote: Not here.. Oh, sorry, I obviously didn't see the @greedy decorator amongst all the quoting levels. Anyway, the idea doesn't make much sense to me :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Why don't generators execute until first yield?

2008-05-07 Thread Marco Mariani
Duncan Booth wrote: Perhaps if you'd copied all of my code (including the decorator that was the whole point of it)... Sure, I missed the point. Python's symbols become quoting levels and mess up messages. Anyway, I would loathe to start execution of a generator before starting to

Re: prove

2008-05-08 Thread Marco Mariani
Lucas Prado Melo wrote: How could I prove to someone that python accepts this syntax using the documentation (I couldn't find it anywhere): classname.functionname(objectname) TUtorial 9.3.4, method objects What exactly happens when a method is called? You may have noticed that x.f() was

source beautifier

2008-05-08 Thread Marco Mariani
Is there a program (free, payware, whatever) like polystyle for linux/python? http://www.polystyle.com/features/python-beautifier.jsp I've never used it, but the example is quite clear. I just need it for python -- but it should not force me to use PEP8. --

Re: How to kill Python interpreter from the command line?

2008-05-08 Thread Marco Mariani
[EMAIL PROTECTED] wrote: The default way of killing the current process on the command line is Ctrl+C, but that doesn't work with Python. It should work. Do you have a bare except: which intercepts SystemExit as well? If so, be as specific as possible in what you intercept, or at least

Re: source beautifier

2008-05-12 Thread Marco Mariani
Stefan Behnel wrote: http://www.polystyle.com/features/python-beautifier.jsp I've never used it, but the example is quite clear. I tend to believe that running these tools on some average Python code would not even change whitespace. ;) I bet it's idempotent against _your_ code, but not in

Re: module global variables

2008-05-12 Thread Marco Mariani
pistacchio wrote: On 12 Mag, 10:01, alex23 [EMAIL PROTECTED] wrote: On May 12, 5:17 pm, pistacchio [EMAIL PROTECTED] wrote: hi to all! can i load a module passing to it, automatically and as default, all the caller's global variables to act as module's global variables? Are you positively

Re: Now what!?

2008-05-12 Thread Marco Mariani
notbob wrote: frustrated and give up on learning programming, not really caring much for coding, anyway. But, dammit, I'm gonna stick with it this time. I'll learn python if it kills me! No, it won't kill you but make you stronger ;) -- http://mail.python.org/mailman/listinfo/python-list

Re: Some comparison operators gone in Python 3.0?

2008-05-13 Thread Marco Mariani
[EMAIL PROTECTED] wrote: Is that true that this comparison operators are gone in Python 3.0: (is less than) (is greater than) = (is less than or equals) = (is greater than or equals) Is it true? Nope. -- http://mail.python.org/mailman/listinfo/python-list

Re: array in class

2008-05-13 Thread Marco Mariani
alefajnie wrote: class B: this_is_common_for_all_instances = [] def __init__(self, v): self.this_is_common_for_all_instances.append(v) now I can create some instances of B, but all of them have the same array, why Because you didn't reassign the attribute

Re: The 'is' identity operator checking immutable values caution

2008-05-13 Thread Marco Mariani
[EMAIL PROTECTED] wrote: We have to avoid the use of the 'is' identity operator with basic, immutable values such as numbers and strings. I'm glad for you. Did you really write checks like if foo is 27 ? The point is, you have to learn technologies to use them. It's not like technologies

Re: Some comparison operators gone in Python 3.0?

2008-05-13 Thread Marco Mariani
alex23 wrote: Given that all nine of his postings have inflammatory topics, he's beginning to sound like a troll. Thank you, I couldn't decide if he was silly or nasty. Now I know he's both. -- http://mail.python.org/mailman/listinfo/python-list

Re: python newbie: some surprises

2008-05-15 Thread Marco Mariani
Kees Bakker wrote: So far, I have seen only one editor that understands the difference between TABs and indentation, and that is Emacs. Oh, well... in .vimrc: autocmd FileType python set tabstop=8 autocmd FileType python set softtabstop=4 autocmd FileType python set expandtab

Re: Battleship style game

2009-02-25 Thread Marco Mariani
Shawn Milochik wrote: I'm not claiming it's bulletproof, but it works. I just kind of came up with all the methods off of the top of my head, so if anyone has any suggestions for more elegant or efficient code, please let me know. Yes it's in Python alright, but it's not Pythonese yet. You

Re: monitoring/restarting an application

2009-03-05 Thread Marco Mariani
Ghirai wrote: I need to keep x number of instances of an external applications running, say /bin/x, but also kill and restart each one after y seconds. What would be the best way to do this (with python 2.5.x)? easy_install supervisor it should do everything for you --

Re: Question about binary file reading

2009-03-05 Thread Marco Mariani
vibgyorbits wrote: l=map(lambda x: '%02x' %ord(x),d) s=string.join(l,sep='') PS#. Endedup learning little bit of Lambda functions. :-) That's so 2007... The 2.5-esque way to write that is s = ''.join('%02x' % ord(x) for x in d) -- http://mail.python.org/mailman/listinfo/python-list

Re: While loop

2009-03-05 Thread Marco Mariani
Fab86 wrote: Is it possible to get the program to catch the exception, wait 10 seconds, then carry of from where it was rather than starting again? something like this? probably works in PASCAL as well :) i=0 while i len(stuff): try: do_with(stuff[i]) except SomeError:

Re: Indentations and future evolution of languages

2009-03-06 Thread Marco Mariani
Steven D'Aprano wrote: You can have one, or the other, but not both, unless you're willing to have a practicality beats purity trade-off and create a second way of grouping blocks, I propose /* and */ as block delimiters. There, you have auto-documenting code, ahah! --

Re: Can Python do shopping cart?

2009-03-06 Thread Marco Mariani
Lie Ryan wrote: Python is Turing Complete Well, actually no, because it doesn't support an infinite amount of memory. Add this to things to check before wasting a lot of money in hardware. -- http://mail.python.org/mailman/listinfo/python-list

Re: Can Python do shopping cart?

2009-03-06 Thread Marco Mariani
Tim Wintle wrote: Python is Turing Complete Well, actually no, because it doesn't support an infinite amount of memory. Surely you can address an infinite amount of storage using infinite length integers and a wrapper to files on disk - then it's just your OS's limits that hold it back - so

Re: Is python worth learning as a second language?

2009-03-09 Thread Marco Mariani
ZikO wrote: Do you think python would be good complementary language for C++? Do you think it's worth learning it Absolutely, but it tends to become the first language over time. Don't underestimate its reach. I've re-learned Python 3 or 4 times already, over 11 years :-/ --

Re: A better way to timeout a class method?

2009-03-09 Thread Marco Mariani
John O'Hagan wrote: Is there a concise Pythonic way to write a method with a timeout? No need for threading. Just define a signal handler and call signal.alarm(). See the example at the end of the page: http://docs.python.org/library/signal.html --

Re: functions - where to store them

2009-03-11 Thread Marco Mariani
plsulliv...@gmail.com wrote: I have several functions which I would like to store in a different directory so several programs can use them. I can't seem to find much information about how to call a function if the function code is not actually in the script itself. read the tutorial, look

Re: Python + PostgreSQL

2009-03-17 Thread Marco Mariani
Lobo wrote: I now have a new project to develop web applications using the latest/ best possible versions of Python (3.x?) with PostgreSQL (8.x?, with pgAdmin 1.10?). You want to use Python 2.5.x (or 2.6 if your framework of choice already supports it), Postgres 8.3 and have a look at

Re: Creating 50K text files in python

2009-03-18 Thread Marco Mariani
venutaurus...@gmail.com wrote: for k in range (1,1001): ... k = k+1 Man, you have a trouble with loops, all over. -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating 50K text files in python

2009-03-18 Thread Marco Mariani
venutaurus...@gmail.com wrote: for k in range (1,1001): ... k = k+1 Man, you have a trouble with loops, all over. But the situation demands it.:-( No. I mean, the for loops are wrong. Compare with the following and see why import os base = '/tmp/foo' for outer in

Re: Style formating of multiline query, advise

2009-03-19 Thread Marco Mariani
someone wrote: Also, for SQL, (A) why are you using nested joins?, and inner select produce smaller set which is then joined with other table, kind a optimization Did you time it? I've done some kind of a optimization that slowed queries by tenfold, because postgres didn't need my advice,

Re: Use of HTMLparser to change language

2009-03-20 Thread Marco Mariani
pranav wrote: I am sure there is a python way of solving this problem. The common sense approach (nothing to do with python) would be to rewrite everything to be dynamically generated with a template language - in python those would be TAL, mako, genshi, jinja, whatever ... anything is

Re: Use of HTMLparser to change language

2009-03-20 Thread Marco Mariani
pranav wrote: I am sure there is a python way of solving this problem. The common sense approach (nothing to do with python) would be to rewrite everything to be dynamically generated with a template language - in python those would be TAL, mako, genshi, jinja, whatever ... anything is better

Re: Introducing Python to others

2009-03-26 Thread Marco Mariani
Paddy O'Loughlin wrote: All of the audience will be experienced (4+ years) programmers, almost all of them are PHP developers (2 others, plus myself, work in C, know C#, perl, java, etc.). Show them the same classical design patterns in Java and Python. Explain how it's much more flexible.

Re: difflib and intelligent file differences

2009-03-26 Thread Marco Mariani
hayes.ty...@gmail.com wrote: My first thought is to do a sweep, where the first sweep takes one line from f1, travels f2, if found, deletes it from a tmp version of f2, and then on to the second line, and so on. If not found, it writes to a file. At the end, if there are also lines still in f1

Re: difflib and intelligent file differences

2009-03-26 Thread Marco Mariani
Marco Mariani wrote: while True: a = filea.readline() b = fileb.readline() if not (a or b): break BTW, watch out for this break. It might not be what you want :-/ -- http://mail.python.org/mailman/listinfo/python-list

Re: difflib and intelligent file differences

2009-03-26 Thread Marco Mariani
Dave Angel wrote: If the lines are really sorted, all you really need is a merge, D'oh. Right. The posted code works on unsorted files. The sorted case is even simpler as you pointed out. -- http://mail.python.org/mailman/listinfo/python-list

Re: difflib and intelligent file differences

2009-03-26 Thread Marco Mariani
Marco Mariani wrote: If the lines are really sorted, all you really need is a merge, For the archives, and for huge files where /usr/bin/diff or difflib are not appropriate, here it is. #!/usr/bin/env python import sys def run(filea, fileb): p = 3 while True: if p1

Re: script question

2009-04-17 Thread Marco Mariani
Piet van Oostrum wrote: funclist = [func01, func02, func03, ... ] for i in range(1,n): funclist[i]() Or myscript.funclist[i]() from another module. Ehm, calling a bazillion things in the right order should be a responsibility of the myscript module anyway. --

Re: Pickled objects over the network

2007-07-25 Thread Marco Mariani
Hendrik van Rooyen ha scritto: But more seriously - is there any need for a simple serialiser that will be able to be used to transfer a subset of the built in types over an open network in a safe manner, for the transfer of things like lists of parameters? Yes, there seems to be a need for

Re: Is anyone happy with csv module?

2007-12-12 Thread Marco Mariani
John Machin wrote: For that purpose, CSV files are the utter pox and then some. Consider using xlrd and xlwt (nee pyexcelerator) to read (resp. write) XLS files directly. xlwt is unreleased (though quite stable, they say) at the moment, so the links are: easy_install xlrd svn co

Re: Is anyone happy with csv module?

2007-12-12 Thread Marco Mariani
massimo s. wrote: As for people advicing xlrd/xlrwt: thanks for the useful tip, I didn't know about it and looks cool, but in this case no way I'm throwing another dependency to the poor users of my software. Csv module was good because was built-in. The trouble with sending CSV files to

Re: Is Python really a scripting language?

2007-12-13 Thread Marco Mariani
Bruno Desthuilliers wrote: As far as I'm concerned, anyone (I mean, anyone pretending to be a programmer) being ignorant enough to ask such a question ranks high in my bozo list. Don't waste time with bozos. Alan Kay said it well enough without using words like pretending, ignorant and

Re: Newbie observations

2007-12-19 Thread Marco Mariani
[EMAIL PROTECTED] wrote: 10 days is not enough. But I don't have any more clarity in my Python classes than I did in Java. You do when you start using classes the python way, and do things that are not even thinkable in java or any static language. --

Re: Iteration for Factorials

2007-10-22 Thread Marco Mariani
Py-Fun wrote: I'm stuck trying to write a function that generates a factorial of a number using iteration and not recursion. Any simple ideas would be appreciated. As opposed to what, a complicated one? -- http://mail.python.org/mailman/listinfo/python-list

Re: Iteration for Factorials

2007-10-22 Thread Marco Mariani
Py-Fun wrote: def itforfact(n): while n100: print n n+1 n = input(Please enter a number below 100) You function should probably return something. After that, you can see what happens with the result you get. -- http://mail.python.org/mailman/listinfo/python-list

Re: Iteration for Factorials

2007-10-22 Thread Marco Mariani
From the cookbook, this time. It satisfies the requirements nicely ;) http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691 def tail_recursion(g): ''' Version of tail_recursion decorator using no stack-frame inspection. ''' loc_vars ={in_loop:False,cnt:0}

Re: Check File Change Every 10 Seconds

2007-10-22 Thread Marco Mariani
Robert Rawlins - Think Blue wrote: That certainly looks to be the type of thing that I'm looking to achieve, however, I forgot to mention I'm running this on a Linux platform and not a Win32 one :-( Sorry. Did you try python-gamin? Gamin is a file and directory monitoring system defined to

Re: Iteration for Factorials

2007-10-22 Thread Marco Mariani
Tim Golden wrote: From the cookbook, this time. It satisfies the requirements nicely ;) http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691 [... snip the ultimate general-purpose answer to the OP's question ... I really hope that's a wink up there, Marco. The wink is in

Re: Iteration for Factorials

2007-10-23 Thread Marco Mariani
Tim Chase wrote: fact = lambda i: i 1 and reduce(mul, xrange(1, i+1)) or not i and 1 or None Stunts like this would get a person fired around here if they were found in production code :) eheh, indeed. def fact(n): try: return eval('*'.join(str(x) for x in range(1,n+1)))

Re: Iteration for Factorials

2007-10-23 Thread Marco Mariani
Roberto Bonvallet wrote: import urllib import re urllib.URLopener.version = Mozilla/4.0 def fact(x): r = re.compile(r%d ! = (\d+) % x) for line in urllib.urlopen(http://www.google.cl/search?q=%d%%21; % x): m = r.search(line) if m: return

Re: Iteration for Factorials

2007-10-23 Thread Marco Mariani
[EMAIL PROTECTED] wrote: Needs work. Uh... ok.. this one gives an exception ;-) def fact(n): try: return eval('*'.join(str(x) for x in range(1,n+1))) except: return n=0 or ValueError print fact(-1) type 'exceptions.ValueError' --

Re: Iteration for Factorials

2007-10-26 Thread Marco Mariani
[EMAIL PROTECTED] wrote: class fact_0(object): value = 1 [... def __new__(self, n_): class spanish_inquisition(object): __metaclass__ = fact_meta n = n_ return spanish_inquisition() You wrote lots of

Re: Iteration for Factorials

2007-10-30 Thread Marco Mariani
Nick Craig-Wood wrote: Note you can write your middle loop as for i in range(I): number = myNumer[:] random.shuffle(number) if number == myNumer: count+=1 Nice. Try 'em all, then count 'em. Another wtfery would be a SQLAlchemy solution, generating

Re: Pythonic ORM with support for composite primary/foreign keys?

2007-11-06 Thread Marco Mariani
Wolfgang Keller wrote: so far it seems to me as if the only ORM module for Python which supports composite primary/foreign keys was SQLAlchemy. Which looks a little bit overbloated for my needs: I just need to be able to define a logical model (à la UML) in Python and have the ORM connect

Re: Haskell like (c:cs) syntax

2007-08-29 Thread Marco Mariani
Ricardo Aráoz ha scritto: L = ['one', 'two', 'three', 'four', 'five'] print L[0]# This would be 'head' print L[1:] # This would be 'tail' Caution : L[0] and L[1:] are COPIES of the head and tail of the list. This might surprise people who see L[1:] = [], since changing a copy is

Re: Python surpasses Perl in popularity?

2008-11-26 Thread Marco Mariani
Steve Holden wrote: In fact all that's really happened is that Perl has slid down the ranks, at least temporarily. Python has been around the 6/7 mark for a while now. Also.. can someone attempt to explain the funny correlation in popularity over time between, for instance, Python and

Re: Pythonic design patterns

2008-12-04 Thread Marco Mariani
George Sakkis wrote: This is all very good, but don't drink the design pattern Kool-Aid and start pushing design patterns everywhere. (Not everything needs to be a singleton. No, really.) Obligatory reading: http://www.mortendahl.dk/thoughts/blog/view.aspx?id=122 By the way, it's a fact

Re: Don't you just love writing this sort of thing :)

2008-12-05 Thread Marco Mariani
Steven D'Aprano wrote: Gosh Lawrence, do tell, which category do YOU fall into? I suppose a mix-up between a cowbody (or Fonzie) coder and a troll. His programs have an inner poetry that we're obviously too stupid to understand. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is slow

2008-12-12 Thread Marco Mariani
Giampaolo Rodola' wrote: The real (and still unsolved) problem with PyPy is the installation which requires something like a dozen of third-party packages to be installed. Unfortunately it seems there are no plans yet for releasing any Windows/Linux/Mac installer in the near future. I'm not

Re: Removing None objects from a sequence

2008-12-12 Thread Marco Mariani
Filip Gruszczyński wrote: I am not doing it, because I need it. I can as well use if not elem is None, I suggest if elem is not None, which is not quite the same. If you slip such an error in a post, I suggest to practice some time writing correct code before having one-liner contests with

Re: Removing None objects from a sequence

2008-12-12 Thread Marco Mariani
Kirk Strauser wrote: So what's the difference exactly? foo is not None is actually surprising to me, since not None is True. 0 is True is False, but 0 is not None is True. Why is that? Cause I was tired of course, and got the not precedente not right!! Argh --

Re: Selecting a different superclass

2008-12-17 Thread Marco Mariani
psaff...@googlemail.com wrote: The problem is that IDPointSet and MicroArrayPointSet will need to inherit from PointSet or TraceablePointSet based on whether I'm handling traceable points or not. Can I select a superclass conditionally like this in Python? Am I trying to do something really

Re: Selecting a different superclass

2008-12-17 Thread Marco Mariani
Marco Mariani wrote: I think you should investigate something different than subclassing, like a Strategy domain pattern or something similar. s/domain/design/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's popularity

2008-12-22 Thread Marco Mariani
walterbyrd wrote: I have read that python is the world's 3rd most popular language, and that python has surpassed perl in popularity, but I am not seeing it. In 20 days, you've gone from trying to import a module by using: load test.py to questioning the popularity of python. You have

Re: Python's popularity

2008-12-22 Thread Marco Mariani
Richard Riley wrote: One does not have to by a language maestro to try and assess its popularity. While his numbers or his reading of the numbers might be open to some questions, to suggest that one needs to be totally familiar with a language to determine its popularity is, frankly,

Re: Line completion with custom commands

2009-01-09 Thread Marco Mariani
gu wrote: I see, but how does django-admin work, then? from bash: complete -W doSomething doSomethingElse doSomethingDifferent myProgram -- http://mail.python.org/mailman/listinfo/python-list

Re: MySQLdb LIKE '%%%s%%' problem

2009-01-14 Thread Marco Mariani
Steve Holden wrote: 3. I can't be certain my experience with PostgreSQL extends to MySQl, but I have done experiments which prove to my satisfaction that it isn't possible to parameterize LIKE arguments. So the only way to do it appears to be to build the query yourself. Or using Postgres

Re: English-like Python

2009-01-19 Thread Marco Mariani
The Music Guy wrote: Just out of curiousity, have there been any attempts to make a version of Python that looks like actual English text? Many have tried that in the decades, but IMHO the best approach is to just rename the language. We cannot do that since it's already been trademarked

Re: How to get first/last day of the previous month?

2009-01-20 Thread Marco Mariani
Hussein B wrote: I'm creating a report that is supposed to harvest the data for the previous month. So I need a way to get the first day and the last day of the previous month. Would you please tell me how to do this? Thanks in advance. dateutil can do this and much, much more. from

Re: How to get first/last day of the previous month?

2009-01-20 Thread Marco Mariani
Carsten Haese wrote: In order to not deprive you of the sense of accomplishment Sorry for spoiling that. If you still want the sense of accomplishment, try to reimplement dateutil (and rrule). It's not as easy as it seems :-o -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get first/last day of the previous month?

2009-01-20 Thread Marco Mariani
Carsten Haese wrote: dateutil can do this and much, much more. Using dateutil for this is like using a sledgehammer to kill a fly. The task at hand can (and IMHO should) be solved with the standard datetime module. Sure, but many python programmers are not even aware of the existence of

Re: Importing modules

2009-01-21 Thread Marco Mariani
Mudcat wrote: This is something I've wondered about for a while. I know that theoretically Python is supposed to auto-recognize duplicate imports; however I've run into problems in the past if I didn't arrange the imports in a certain way across multiple files. I think you've probably had

Re: ORM recommendation when using live/predefined DB?

2009-01-28 Thread Marco Mariani
Phillip B Oldham wrote: Can you recommend an ORM (or similar) package to look into? SQLAlchemy with reflected tables. You can use straight SQL, generate it dynamically via python expressions, go with the ORM, or everything together (in a bucket :) It really pays due respect to the RDBMS,

Re: is python Object oriented??

2009-02-03 Thread Marco Mariani
Thorsten Kampe wrote: This scenario is highly supposing and doesn't look like a real-world- case to me. But anyway: the obvious solution in my humble opinion would be to do something like public_attribute = _private_attribute. But that would be too simple, too unjavaesque, right?! Yes, the

Re: what IDE is the best to write python?

2009-02-03 Thread Marco Mariani
Russ P. wrote: highlighting. Not that it really helps much, but it spices up the code and stimulates the eyes and brain. When I see the same code without color highlighting, it just seems bland, like something is missing. It seems like just text rather than code. Plus, it can be configured to

Re: len()

2009-02-04 Thread Marco Mariani
Pat wrote: Why didn't you answer the len() question? It's a bit of a FAQ: len() cannot be a method of list objects because it works on any sequence or iterable. -- http://mail.python.org/mailman/listinfo/python-list

Re: A little bit else I would like to discuss

2009-02-13 Thread Marco Mariani
azrael wrote: I know that there is already a standard python library, But why not extending it. classify the standard library into subcategories like Networking, DataBase, Computation, .. If the standard library where that huge, python 3.0 would have been late by a couple of years.

Re: best set of modules for web automation without javascript

2009-02-13 Thread Marco Mariani
News123 wrote: I would just like to retrieve all the field names and default values of a form. (Some forms are huge) and wondered thus whether there's already a python module parsing a html documents for forms , form fields and field vaules, returning an objcet. that could be modified and

  1   2   >