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 f

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

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 n<100: > 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

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 wi

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,

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: > retu

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) -- http://mail.python.org/mailman/listinfo/python-list

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 o

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, gene

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

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 https://s

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"

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. -- http://mail.python.org/mailman/listinfo

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

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 thro

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 fo

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 date

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 tha

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 issu

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, and

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,

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 configur

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. Why

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 posted

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 Delphi?

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 that

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 us

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 w

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 -- http://mail.python.org

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 evil

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, ridiculous.

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: "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 -- http://mail.python.org

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: s

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! -- http://mail.python.o

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 p

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 :-/ -- http://mail.py

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 -- http://mail.python.org/mailman/listinfo/pyt

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 for

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 SQLAlch

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 x

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 bett

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 t

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 t

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 p&

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. -- http://mail.python.org/mai

Re: Is there a programming language that is combination of Python and Basic?

2009-04-20 Thread Marco Mariani
Michael Torrie wrote: http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html Somebody better tell the Linux kernel developers about that! They apparently haven't read that yet. Better tell CPU makers too. In assembly it's all gotos. I'm sure you are joking.

Re: Is there a programming language that is combination of Python and Basic?

2009-04-20 Thread Marco Mariani
baykus wrote: those "lines" as numbered steps or numbered bricks that are sitting on eachother but I see them as timelines or like filmstrips. Anyways it sounds like such a toy programming language does not exists except Arnaud surprisingly efficient code. and I will search my dream somewhere e

Re: Memory footpring of python objects

2009-04-22 Thread Marco Mariani
BlueBird wrote: I have a program that manages several thousands instances of one object. To reduce memory consumption, I want of course that specific object to have the smallest memory footpring possible. Have you thought of using something like the flyweight pattern and a compact data repres

Re: namespace query

2009-04-22 Thread Marco Mariani
Dr Mephesto wrote: Why are the class files I created not seeing the top namespace? Because it's how python works. What you think is a top namespace, it's not "at the top". It's just the namespace of the module you run the program with. You must import numpy from the all the modules that make

Re: namespace query

2009-04-22 Thread Marco Mariani
Dr Mephesto wrote: ok, sorted. I had thought that when a module was imported, it was added to a larger shared namespace used by all the modules. Now, that would be awfulll Because one of the most important things about python (and the reason I can live without an IDE) is that I can point my

Re: New fonts for python docs site

2009-04-23 Thread Marco Mariani
Mark wrote: e.g. see http://docs.python.org/library/index.html Please tell me this is a mistake? 3.X docs are the same. Looks ok. What do you see? -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Packages : A looming problem? packages might no longer work? (well not on your platform or python version anyway)

2009-04-23 Thread Marco Mariani
David Lyon wrote: What if I decide to write only to Python 3? Fair enough. But don't forget it is open source. So what? Let me ask these two questions... - What about the use case where somebody likes the code and wants to use it on Python 2.5? A patch, a fork, whatever. - Should

Re: Unicode in writing to a file

2009-04-23 Thread Marco Mariani
Carbon Man wrote: Py 2.5 Trying to write a string to a file. self.dataUpdate.write(u"\nentry."+node.tagName+ u" = " + cValue) cValue contains a unicode character. node.tagName is also a unicode string though it has no special characters in it. So what's the encoding of your file? If you didn

Re: Why can function definitions only use identifiers, and not attribute references or any other primaries?

2009-04-23 Thread Marco Mariani
Jeremy Banks wrote: I've read those discussion before, but somehow never made the connection between those and this. I'll give that article a read, it probably details exactly the perspective I'm looking for. Thank you! You could also read this: http://unlimitednovelty.com/2009/03/indentation

Re: Why can function definitions only use identifiers, and not attribute references or any other primaries?

2009-04-24 Thread Marco Mariani
Scott David Daniels wrote: I am afraid it will make it too easy to define functions in other modules remotely, a tempting sharp stick to poke your eye out with. It's not very hard at the moment, and I don't see lots of eyes flying by. I don't know about Ruby where monkeypatching seems to be c

Re: if statement, with function inside it: if (t = Test()) == True:

2009-04-24 Thread Marco Mariani
Ulrich Eckhardt wrote: t = Test() if (t == 'Vla': print t # must contain Vla What's wrong with that? It unnecessarily injects the name 't' into the scope. Since there is no concept in Python of a scope local to block statements, I don't understant what you would like to happen instead

Re: Lisp mentality vs. Python mentality

2009-04-27 Thread Marco Mariani
Scott David Daniels wrote: I don't remember who, but something famously said, in effect: Debugging is hard, maybe twice as hard as writing the code in the first place. Unless you are one of those nonexistent few He would be the K in K&R. -- http://mail.python.org/mailman/listinfo/pyth

Re: Web based application development using python

2009-04-28 Thread Marco Mariani
Rahul wrote: 1) Do you have any idea about web based support (like mod_python) provided by python.org (official web site) Details: - As we know mod_python is used for embeding python code into apache server. so, i want to know whether mod_python is officially supported by python.org or if there

Re: Geohashing

2009-04-29 Thread Marco Mariani
djc wrote: Python 2.5.2 (r252:60911, Oct 5 2008, 19:29:17) geohash(37.421542, -122.085589, b'2005-05-26-10458.68') ^ SyntaxError: invalid syntax The byte type is new in 2.6 -- http://mail.python.org/mailman/listi

Re: Why bool( object )?

2009-04-29 Thread Marco Mariani
Bruno Desthuilliers wrote: Lawrence D'Oliveiro a écrit : What is the rationale for considering all instances true of a user- defined type? It's a stupid idea, Nope, it's a very sensible default (given you can redefine the 'nothingness' value of your types instances), specially when the

Re: Geohashing

2009-04-30 Thread Marco Mariani
norseman wrote: The posting needs (its creation) ... DATE. ... The code needs to state OS and program and version used to write it. And from there - user beware." Which would reduce the confusion greatly. I got the same error message and decided it was from an incompatible version, using

Re: Tools for web applications

2009-04-30 Thread Marco Mariani
Mario wrote: I used JCreator LE, java IDE for windows because, when I add documentation of some new library, I have it on a F1 and index. So how you manage documentation and code completion ? I asume that you are geek but not even geeks could know every method of every class. What you call

Re: what's the best way to call a method of object without a guarantee of its existence

2009-05-05 Thread Marco Mariani
Leon wrote: One way, define the object before it is used, like this: object = None This is a good practice anyway. Conditional existance of objects is quite evil. Resorting to if defined('foo') is double-plus-ugly. The other way, using try ... catch try: object.method() catch NameEr

Re: what's the best way to call a method of object without a guarantee of its existence

2009-05-06 Thread Marco Mariani
Leon wrote: So I need to go back to the module including "parent" class to define the objects that I maybe use in future as None, You can assign them to a placeholder, with a method that always exists but does nothing. class NullObject(object): def method(self, *args, **kw): pas

Re: How should I use grep from python?

2009-05-07 Thread Marco Mariani
Matthew Wilson wrote: consensus. I could os.popen, commands.getstatusoutput, the subprocess module, backticks, etc. Backticks do_not_do what you think they do. And with py3k they're also as dead as a dead parrot. -- http://mail.python.org/mailman/listinfo/python-list

Re: OOP & Abstract Classes

2009-05-11 Thread Marco Mariani
Mike Driscoll wrote: I've never used (or heard of) the Abstract type...and the guy who wrote the FAQ was being a jerk. Who, Peter Norvig? (from wikipedia) Peter Norvig is an American computer scientist. He is currently the Director of Research (formerly Director of Search Quality) at Google

Re: Pycon Tre, grazie!

2009-05-12 Thread Marco Mariani
daniele wrote: Si è concluso ieri la pycon tre, è stata molto interessante, un bel evento per una bella comunità. Sempre meglio.. anche se mi preoccupa un po' un eventuale cambio di location Ho visto con grande piacere, oltre all'incremento dei partecipanti, anche un sensibile incremento del

Re: introspection question: get return type

2009-05-14 Thread Marco Mariani
Bruno Desthuilliers wrote: Oh, you meant the "return type" ? Nope, no way. It just doesn't make sense given Python's dynamic typing. I thought that the OP was writing a tool to document not-very-dynamic code. Unless he's really trying to write in Nohtyp, the language where value types are mo

Re: Just wondering

2009-05-15 Thread Marco Mariani
Gediminas Kregzde wrote: def doit(i): pass def main(): a = [0] * 1000 t = time() map(doit, a) print "map time: " + str(time() - t) Here you are calling a function ten million times, build a list with of ten million None results, then throw it away. def main2(): t =

Re: Seeking old post on developers who like IDEs vs developers who like simple languages

2009-05-18 Thread Marco Mariani
Steve Ferg wrote: I periodically think of that blog, usually in circumstances that make me also think "Boy, that guy really got it right". But despite repeated and prolonged bouts of googling I haven't been able to find the article again. I must be using the wrong search terms or something. D

Re: ? 'in' operator and fallback to __getitem__

2009-05-18 Thread Marco Mariani
timh wrote: However strange things happen to the name passed to __getitem__ in the following example (and in fact in all varients I have triend the name/ key passed to __getitem__ is always the integer 0 I think it's scanning the container as a sequence and not as a mapping, hence the access

Re: Seeking old post on developers who like IDEs vs developers who like simple languages

2009-05-19 Thread Marco Mariani
Chris Rebert wrote: On the other hand there are developers who much prefer to keep things light-weight and simple. Would it be fair to say the first type tends to congregate in herds, particularly in corporate IT departments, while the latter tends to operate on a more individual basis? That

Re: sqlite3, qmarks, and NULL values

2009-05-20 Thread Marco Mariani
Mitchell L Model wrote: def lookupxy(x, y): if y: conn.execute("SELECT * FROM table WHERE COL1 = ? AND COL2 = ?", (x, y)) else: conn.execute("SELECT * FROM table WHERE COL1 = ? AND COL2 IS NULL", (x,))

Re: Trying to understand a very simple class - from the book "dive into python"

2009-05-20 Thread Marco Mariani
walterbyrd wrote: > I am sure this is totally simple, but I missing something. Do you know what a dictionary is? -- http://mail.python.org/mailman/listinfo/python-list

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 positivel

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 'this_is_

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 l

  1   2   >