Re: Building a multiline string

2010-02-04 Thread Marco Mariani
On 02/04/2010 12:34 PM, lallous wrote: > Now should I be using method 2 or 3 in production code? Another way... depending on what you are using the string for, of course. If it's an HTML/XML/SQL/whatever piece of code: from textwrap import dedent sql = dedent(""" > ... SEL

Re: Are routine objects guaranteed mutable & with dictionary?

2009-12-04 Thread Marco Mariani
Alf P. Steinbach wrote: Is this guaranteed to work in Python 3.x? >>> def foo(): pass >>> foo.blah = 222 >>> foo.blah 222 >>> _ I don't see why it shouldn't work. BTW, it's a function, not a "routine" -- http://mail.python.org/mailman/listinfo/python-list

Re: Exec Statement Question

2009-11-30 Thread Marco Mariani
Jean-Michel Pichavant wrote: if which == '': i = 0 all = '' while i < len(meanings): table = '%s\n' % meanings[i] table += "\n \n composing HTML like that is painful, bug prone and insecure You should have a look at http://tottinge.blogsome.com/meaningfulnames/ I

Re: problem with lambda / closures

2009-11-30 Thread Marco Mariani
Louis Steinberg wrote: I have run into what seems to be a major bug, but given my short exposure to Python is probably just a feature: Yes, it works as advertised :-/ which I would expect. Can anyone explain this or give me a workaround? like this? def p(d): print d l=[ ] for

Re: Python Statements/Keyword Localization

2009-11-30 Thread Marco Mariani
Terry Reedy wrote: A 'pro' argument: Python was designed for learning and is good for that and *is* used in schools down to the elementary level. But kids cannot be expected to know foreign alphabets and words whill still learning their own. I taught myself BASIC at 9 by reading magazines, b

Re: How to Detect Use of Unassigned(Undefined) Variable(Function)

2009-11-30 Thread Marco Mariani
Jon Clements wrote: pychecker returns "test.py:3: No global (o) found" for the above, and can be found at http://pychecker.sourceforge.net/ There's also pylint and another one whose name I can't remember... pyflakes. I use that one -- http://mail.python.org/mailman/listinfo/python-list

Re: how to format a python source file with tools?

2009-11-27 Thread Marco Mariani
??,??? wrote: or is it possible for large source files? Google for polystyle. It's a tool that reformats a program (in several languages) using an example you must provide (let's call it a "style sheet", written in Python or whatever) of how you would want to format it. You can then refo

Re: hex int and string

2009-11-27 Thread Marco Mariani
Ben Finney wrote: i'm using pyscard I don't know what that is; can you give a link to what you're referring to? Simple story: he has seen the examples with hex literals and didn't know what they were. -- http://mail.python.org/mailman/listinfo/python-list

Re: hex int and string

2009-11-27 Thread Marco Mariani
luca72 wrote: i have checked and pyscard accept also the decimal notation, I'm not sure you ever understood what the problem was, or where, but I'm happy you feel like you've solved it. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Statements/Keyword Localization

2009-11-26 Thread Marco Mariani
Emanuele D'Arrigo wrote: In this context it seems to be the case that the executable would have to be able to optionally accept -a list- of dictionaries to internally translate to English the keywords found in the input code and at most - one- dictionary to internally translate from English outp

Re: TODO and FIXME tags

2009-11-20 Thread Marco Mariani
Jean-Michel Pichavant wrote: I guess the world is split in two categories, those how come back to fix the TODO, and those how don't. I for myself belong to the second, that is why I never write TODO comments, I either do the stuff or consider this is not important enough to waste time on it. I

Re: is None or == None ?

2009-11-10 Thread Marco Mariani
Grant Edwards wrote: MacOS applications made the same mistake on the 68K. And and awful lot of the Amiga software, with the same 24/32 bit CPU. I did it too, every pointer came with 8 free bits so why not use them? It wasn't the decades-long global debacle that was the MS-DOS memory model,

Re: Frameworks

2009-10-19 Thread Marco Mariani
Diez B. Roggisch wrote: I don't read that out of the post, and it almost certainly is wrong, at least on a general level. There isn't much above SQLAlchemy regarding flexibility & power, so while simple cases might be simpler with other ORMs, they often make more complicated ones impossible. Bu

Re: Clear interface for mail class

2009-10-14 Thread Marco Mariani
Benedict Verheyen wrote: Any ideas are welcome. easy_install turbomail :) -- http://mail.python.org/mailman/listinfo/python-list

Re: The rap against "while True:" loops

2009-10-14 Thread Marco Mariani
Dennis Lee Bieber wrote: One thing to note is that "break" ONLY exits the innermost loop -- Ada adds the confusion that one could define a label on the loops, and have the innermost use exit outer_label [when condition] THAT I find scary... Since you have to match the l

Re: Confessions of a Python fanboy

2009-07-30 Thread Marco Mariani
r wrote: My adventures in Ruby. Oh, it's you. Good boy. Now, why don't you have a look at javascript and come back in six months? Or better yet, haskell and twelve months. thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: where do I put resources (images, audio files) when I wrote Python program?

2009-07-28 Thread Marco Mariani
Piotrek wrote: that? I think about puting these files in /usr/share/myprogram and then reading it the normal way (so the path "/usr/share/myprogram" would be just hardwired in my program). Is it the way one usually does it in Python program or is there any more sofisticated way? Just keep them

Re: older pythons

2009-07-09 Thread Marco Mariani
superpollo wrote: what i was asking for is about a way to *INSTALL* and mantain different python versions, a task i think is not unusal for developers. Check out virtualenv, I ask myself how I could work without it. http://pypi.python.org/pypi/virtualenv -- http://mail.python.org/mailman/lis

Re: SPAM-LOW: Re: Function/method returning list of chars in string?

2009-06-09 Thread Marco Mariani
Hendrik van Rooyen wrote: lb = list("banana") Aaargh! I should have known - you use a string method to get a list of words, but you have to go to the list to get a list of characters from a string. As they say, "Python is not Java". Strings support the sequence protocol (aka interface), he

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: 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: 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: ? '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-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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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-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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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
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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: "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: 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: 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: 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: 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: 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: 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: 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: 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: 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
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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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

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

  1   2   >