Python and Flask Book

2021-10-28 Thread Bruno Oliveira
&usg=AOvVaw2RFbMdp7h-toAR8c8BELtO> Best regards, Bruno -- https://mail.python.org/mailman/listinfo/python-list

Re: Compute working days

2021-08-18 Thread Bruno Lirio
Em sábado, 14 de março de 2009 às 13:59:41 UTC-3, Casey escreveu: > How about: > from datetime import date, timedelta > # Define the weekday mnemonics to match the date.weekday function > (MON, TUE, WED, THU, FRI, SAT, SUN) = range(7) > def workdays(start_date, end_date, whichdays=(MON,TUE,WED,THU,

Re: Covariance matrix syntax

2020-10-13 Thread Bruno P. Kinoshita via Python-list
I think the np.cov is from the numpy module (imported/aliased as np?). If so, the numpy repository should have what you are looking for: https://github.com/numpy/numpy/blob/156cd054e007b05d4ac4829e10a369d19dd2b0b1/numpy/lib/function_base.py#L2276 Hope that helps Bruno On Tuesday, 13

Re: ctypes problem: segfault with pointer usage

2015-03-27 Thread Bruno Cauet
Found the problem: I just have to add libgio.g_object_unref.argtypes = [ctypes.c_void_p] It now works flawlessly! Sorry for the noise. 2015-03-27 13:03 GMT+01:00 Bruno Cauet : > Hi, > I have a segfault problem with ctypes. Script attached. > I simply need to call `libgio.g_file_new_for_

ctypes problem: segfault with pointer usage

2015-03-27 Thread Bruno Cauet
ent/response types. What am I doing wrong? Any pointer (ahah) on how to solve my problem? The c code can be compiled that way: $ gcc $(pkg-config --cflags gio-2.0) segfault.c -o segfault $(pkg-config --libs gio-2.0) Thanks Bruno import ctypes import ctypes.util class GioURI(object): "

urllib.parser.quote() and RFC 2396: unreserved characters get encoded

2015-02-11 Thread Bruno Cauet
that URIs generated by python does not match the URIs generated by other tools and make me unable to identify elements as identical because of their URI. Thanks, Bruno -- https://mail.python.org/mailman/listinfo/python-list

Results of the python 2.x and 3.x use survey, 2014 edition

2015-01-29 Thread Bruno Cauet
3, but dependencies keep them with 2.7 (I weep for the few ones still on 2.5). I also posted the results on HN (https://news.ycombinator.com/item?id=8967645) and reddit (http://www.reddit.com/r/Python/comments/2u3oh0/results_of_the_python_2x_and_3x_use_survey_2014/). Have a nice day, and a year

Re: [Python-Dev] Python 2.x and 3.x use survey, 2014 edition

2014-12-11 Thread Bruno Cauet
014 at 3:59 AM, Bruno Cauet wrote: >> Here's the url: http://goo.gl/forms/tDTcm8UzB3 >> I'll publish the results around the end of the year. > On "Which versions do you use?", 3.5 is not included. My primary > Python 3 build on here is a 3.5 built from trun

Python 2.x and 3.x use survey, 2014 edition

2014-12-11 Thread Bruno Cauet
ublish the results around the end of the year. Last year results: https://wiki.python.org/moin/2.x-vs-3.x-survey Thank you Bruno -- https://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] Python 2.x and 3.x use survey, 2014 edition

2014-12-11 Thread Bruno Cauet
inator.com/item?id=8730156 http://redd.it/2ovlwm http://redd.it/2ovls4 Feel free to publish it anywhere else, to get as many answers as possible. Bruno 2014-12-10 18:24 GMT+01:00 Nathaniel Smith : > On 10 Dec 2014 17:16, "Ian Cordasco" wrote: > > > > On Wed, Dec 1

Re: PEP 378: Format Specifier for Thousands Separator

2013-05-21 Thread Alysson Bruno
format(one_number)) number=1,234,567 >>> paz e amor (love and peace), Alysson Bruno === Palmas(TO) Brasil Blog: http://abruno.com Twitter: http://twitter.com/alyssonbruno Facebook: http://www.facebook.com/ProfessorAlyssonBruno ===

Re: How to get the selected text of the webpage in chrome through python ?

2013-01-08 Thread Bruno Dupuis
nd dirty call to xclip -o, although there must be a pure python implementation which in turn depends on the python framework you play with (gtk/qt/wx/tk/...). Short answer is : it depends on your system, and it may be easier and more portable if you use a graphical toolkit. cheers. -- Brun

Re: Where to contribute Unicode General Category encoding/decoding

2012-12-13 Thread Bruno Dupuis
Therefore, it's often better to make a package on PyPI, or, if the code is too short, to submit your handy chunks on ActiveState. If it deserves a general approbation, it may be included in Python stdlib. Cheers -- Bruno -- http://mail.python.org/mailman/listinfo/python-list

Re: Confused compare function :)

2012-12-06 Thread Bruno Dupuis
On Thu, Dec 06, 2012 at 04:32:34AM +, Steven D'Aprano wrote: > On Thu, 06 Dec 2012 03:22:53 +, Rotwang wrote: > > > On 06/12/2012 00:19, Bruno Dupuis wrote: > >> [...] > >> > >> Another advice: never ever > >> > >> except XXXE

Re: Confused compare function :)

2012-12-05 Thread Bruno Dupuis
On Wed, Dec 05, 2012 at 11:50:49PM +0100, Anatoli Hristov wrote: > I'm confused again with a compare update function. The problem is that > my function does not work at all and I don't get it where it comes > from. > > in my DB I have total of 754 products. when I run the function is says: > Total

Re: why does dead code costs time?

2012-12-05 Thread Bruno Dupuis
I added a patch on the issue tracker. It solves the bug for short (<32700 bytes) functions ref : http://bugs.python.org/file28217/16619-1.patch -- Bruno Dupuis -- http://mail.python.org/mailman/listinfo/python-list

Re: why does dead code costs time?

2012-12-05 Thread Bruno Dupuis
On Wed, Dec 05, 2012 at 03:41:19PM -0500, Terry Reedy wrote: > On 12/5/2012 1:24 PM, Bruno Dupuis wrote: > >On Wed, Dec 05, 2012 at 10:59:26AM -0700, Ian Kelly wrote: > >>On Wed, Dec 5, 2012 at 10:34 AM, Steven D'Aprano > >> wrote: > >>>The difference

Re: why does dead code costs time?

2012-12-05 Thread Bruno Dupuis
gt;>> def f(x): > ... return None > ... print(x) > ... > >>> f('test') > 42 This one is pretty scary The difference between `return None` and `return` leads to inconsistency and is in contradiction with the specs, AFAIK. I'm glad we pointed this out. -- Bruno Dupuis -- http://mail.python.org/mailman/listinfo/python-list

Re: How does one make argparse print usage when no options are provided on the command line?

2012-12-05 Thread Bruno Dupuis
a separate usage statement. So they used argparse for everything but the > case where no command line args are given. > this is quite raw, but i'd add import sys if len(sys.argv) == 1: sys.argv.append('-h') before I call parser.parse_args() Should work -- Bruno Dup

Re: why does dead code costs time?

2012-12-05 Thread Bruno Dupuis
On Wed, Dec 05, 2012 at 05:40:51PM +0100, Bruno Dupuis wrote: > On Wed, Dec 05, 2012 at 04:15:59PM +, Neil Cerutti wrote: > > Maybe it's the difference between LOAD_CONST and LOAD_GLOBAL. We > > can wonder why g uses the latter. > > Good point! I didn't even no

Re: why does dead code costs time?

2012-12-05 Thread Bruno Dupuis
On Wed, Dec 05, 2012 at 04:15:59PM +, Neil Cerutti wrote: > On 2012-12-05, Bruno Dupuis wrote: > > Hi, > > > > I'm interested in compilers optimizations, so I study python > > compilation process > > > > I ran that script: > > > >

why does dead code costs time?

2012-12-05 Thread Bruno Dupuis
mmhh... it comes to me now that the gap must be in function loading time... I'll check ceval.c However, isn't there a room for a slight optim here? (in this case, the dead code is obvious, but it may be hidden by complex loops and conditions) Cheers -- Bruno Dupuis -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiplication error in python

2011-09-27 Thread Alysson Bruno (WebSite)
In my python 3.2, no problem: >>> l=[1,2,3,4,5] >>> i=0 >>> for a in l: ... p=2*a ... t=p+i ... i=t ... print("p={}, t={}, i={}".format(p,t,i)) ... p=2, t=2, i=2 p=4, t=6, i=6 p=6, t=12, i=12 p=8, t=20, i=20 p=10, t=30, i=30 >>> t 30 >>&

Instituições que utilizam Python.

2011-08-29 Thread Bruno Andrade
instituições que criam aplicações para terceiros usando a linguagem Python. Acredito que talvez, vocês contenham uma lista com essas instituições que utilizam Python. Desde já agradeço a sua atenção; Muito Obrigado; Att; Bruno Andrade. -- http

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Bruno Piguet
your needs. Note that if you use the second optionnal argument of next, you'll need an additional pair of parentheses around the generator expression which is the first argument of next. Bruno. -- http://mail.python.org/mailman/listinfo/python-list

Re: functions, list, default parameters

2010-11-03 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : In message <20101021235138.609fe...@geekmail.invalid>, Andreas Waldenburger wrote: While not very commonly needed, why should a shared default argument be forbidden? Because it’s safer to disallow it than to allow it. Then there are quite a few python features

Re: Python documentation too difficult for beginners

2010-11-02 Thread Bruno Desthuilliers
jk a écrit : Hi, I've been coding in PHP and Java for years, and their documentation is concise, well structured and easy to scan. Others have mentioned this apparently for years (see: http://stackoverflow.com/questions/4046166/easy-to-navigate-online-python-reference-manual/4070851 and http://

Re: sequence multiplied by -1

2010-10-03 Thread Bruno Desthuilliers
Stefan Schwarzer a écrit : > One could argue that using L[::-1] isn't "obvious" It *is* obvious - once you've learned slicing. "obvious" doesn't mean you shouldn't bother reading the FineManual. -- http://mail.python.org/mailman/listinfo/python-list

Re: singleton problems

2010-10-03 Thread Bruno Desthuilliers
jimgardener a écrit : > hi Steven, > can you explain that?I didn't quite get it. > I have a module say 'managerutils' where I have a class > MyManager.. What Steven was talking about was to NOT use a class at all. Modules are objects and have their own namespace. And you can use threading.locals i

Re: Calling an arbitrary function with the right arguments

2010-09-27 Thread Bruno Desthuilliers
John O'Hagan a écrit : How to call a function with the right arguments without knowing in advance which function? (snip) For most use case I can think of, I can only second Steven and Chris - if your functions are interchangeable then they should have a same API. Now there's at least one u

Re: This Is International Don’t-Squawk-Like-A -Parrot Day

2010-09-22 Thread Bruno Desthuilliers
Lawrence D'Oliveiro a écrit : Next we need an International Surfin’ Bird day, a day to go around and tell everybody that the bird bird bird, the bird is the word. +1 -- http://mail.python.org/mailman/listinfo/python-list

Re: elementwise multiplication of 2 lists of numbers

2010-09-20 Thread Bruno Desthuilliers
harryos a écrit : hi I have 2 lists of numbers,say x=[2,4,3,1] y=[5,9,10,6] I need to create another list containing z=[2*5, 4*9, 3*10, 1*6] ie =[10,36,30,6] I did not want to use numpy or any Array types.I tried to implement this in python .I tried the following z=[] for a,b in zip(x,y):

Re: newbie: class and __dict__ variable.

2010-09-20 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : On Mon, 20 Sep 2010 09:27:25 +0200, Bruno Desthuilliers wrote: If the class has a .__setattr__ method, the first bypasses that method, It also bypasses object.__setattribute__ and - as a consequence - any binding descriptor by the same name as the attribute bein

Re: Learning inheritance

2010-09-20 Thread Bruno Desthuilliers
Niklasro a écrit : Good to learn what I'm doing :-) since important being able to explain choices taken farther than "doing it because it works". I understand the concept of modules may not correspond to java programming where I come from. Coming from Java - and specially if you only have exper

Re: Learning inheritance

2010-09-20 Thread Bruno Desthuilliers
alex23 a écrit : Python only actually executes a module the first time it's imported, Beware of multithreading and modules imported under different names... There can be issues with both in some web frameowrks. -- http://mail.python.org/mailman/listinfo/python-list

Re: newbie: class and __dict__ variable.

2010-09-20 Thread Bruno Desthuilliers
Terry Reedy a écrit : On 9/19/2010 1:37 PM, mafeu...@gmail.com wrote: Hallo Group Members. From time to time I see in python code following notation that (as I believe) extends namespace of MyClass. No, it does not affect MyClass, just the instance dict. class MyClass: def __init__(sel

Re: program organization question for web development with python

2010-09-17 Thread Bruno Desthuilliers
Hans a écrit : (snip) Maybe I did not make my question clear. I never tried python web programing before, so I want to start from CGI. You can indeed learn quite a few things doing raw CGI - the most important one being why frameworks are a good idea !-) I read something about web framewor

Re: Multiprocessing Queue strange behavior

2010-09-16 Thread Bruno Oliveira
e code work all time. That is the main reason I believe there is a problem in the Queue code somewhere. Cheers, On Wed, Sep 15, 2010 at 5:47 PM, MRAB wrote: > On 15/09/2010 21:10, Bruno Oliveira wrote: > >> Hi list, >> >> I recently found a bug in my company&#

Multiprocessing Queue strange behavior

2010-09-15 Thread Bruno Oliveira
Hi list, I recently found a bug in my company's code because of a strange behavior using multiprocessing.Queue. The following code snippet: from multiprocessing import Queue queue = Queue() queue.put('x') print queue.get_nowait() Fails with: ... File "E:\Shared\dist-0902\i686.win32\processin

Re: help with calling a static method in a private class

2010-09-14 Thread Bruno Desthuilliers
Diez B. Roggisch a écrit : lallous writes: How can I keep the class private and have the following work: [code] class __internal_class(object): @staticmethod def meth1(s): print "meth1:", s @staticmethod def meth2(s): print "meth2:", __internal_class.m

Re: Refactoring similar subclasses

2010-09-13 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : I have some code that currently takes four different classes, A, B, C and D, and subclasses each of them in the same way: class MyA(A): def method(self, x): result = super(MyA, self).method(x) if result == "spam": return "spam spam spam"

Re: inspect the call stack

2010-09-10 Thread Bruno Desthuilliers
bussiere bussiere a écrit : i v'e got this : i've got toto.py : import titi def niwhom(): pass and titi.py : def nipang(): pass how can i know in titi.py that's it's toto.py that is calling titi.py and the path of toto ? how can i inspect the call

Re: include a file in a python program

2010-09-10 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : On Mon, 06 Sep 2010 00:57:30 +0200, bussiere bussiere wrote: i've got a python.txt that contain python and it must stay as it (python.txt) Why? Is it against the law to change it? *wink* how can i include it in my program ? import python.txt doesn't work You co

Re: accessing a text file

2010-09-08 Thread Bruno Desthuilliers
Baba a écrit : "Dear xyz, Your question can easily be researched online. We suggest you give it a try and to look it up yourself. This will be beneficial both to you and to us. We do encourage to ask questions only when they have been researched first." On usenet - as well as on most technical

Re: The Samurai Principle

2010-09-07 Thread Bruno Desthuilliers
Phlip a écrit : > On Sep 7, 10:36 am, Ian Kelly wrote: >> On Tue, Sep 7, 2010 at 10:02 AM, Phlip wrote: >>> Back to the topic, I tend to do this: >>> for record in Model.objects.filter(pk=42): >>> return record >>> return sentinel >> How is that any better than just catching the exception?

Re: The Samurai Principle

2010-09-07 Thread Bruno Desthuilliers
Phlip a écrit : > On Sep 7, 10:12 am, Bruno Desthuilliers 42.desthuilli...@websiteburo.invalid> wrote: >> Phlip a écrit : >> >>> Back to the topic, I tend to do this: >>> for record in Model.objects.filter(pk=42): >>> return record >>&g

Re: The Samurai Principle

2010-09-07 Thread Bruno Desthuilliers
Phlip a écrit : Back to the topic, I tend to do this: for record in Model.objects.filter(pk=42): return record return sentinel WTF alert here... Having lots of short methods helps, because return provides both control-flow and a result value. But it abuses 'for' to mean 'if'. I fee

Re: knowing the caller of an import && exec question

2010-09-07 Thread Bruno Desthuilliers
bussiere bussiere a écrit : i've got toto.py : import titi def niwhom(): pass and titi.py : def nipang(): pass how can i know in titi.py that's it's toto.py that is calling titi.py and the path of toto ? You'd have to inspect the call stack. Not for the faint at heart... And w

Re: Help needed - function apparently global cannot be called.

2010-09-07 Thread Bruno Desthuilliers
Ian Hobson a écrit : (snip) you may also want to read the recent "using modules" thread... -- http://mail.python.org/mailman/listinfo/python-list

Re: The Samurai Principle

2010-09-07 Thread Bruno Desthuilliers
Phlip a écrit : How does that compare to, say, the "Kamikaze Principle"? ;) Return victorious AND not at all! (All return values are packed up and thrown...;) ... and then it raises a SystemError !-) -- http://mail.python.org/mailman/listinfo/python-list

Re: mutate dictionary or list

2010-09-07 Thread Bruno Desthuilliers
Baba a écrit : Hi I am working on an exercise which requires me to write a funtion that will check if a given word can be found in a given dictionary (the hand). def is_valid_word(word, hand, word_list): """ Returns True if word is in the word_list and is entirely composed of letter

Re: accessing a text file

2010-09-07 Thread Bruno Desthuilliers
Baba a écrit : (snip) If i had received a friendly response from Benjamin (as opposed to "Please do us a favor and at least try to figure things out on your own") According to usenet standards and given your initial question, this is a _very_ friendly answer. -- http://mail.python.org/mailman

Re: Help needed - function apparently global cannot be called.

2010-09-07 Thread Bruno Desthuilliers
Ian Hobson a écrit : Hi all you experts, This has me beat. Has anyone any ideas about what might be going wrong? This is code from within a windows service (hence no print statements - no sys.stdout to print on!). I am trying to trace through to find where the code is not working. No stdout

Re: Subclassing by monkey-patching

2010-09-06 Thread Bruno Desthuilliers
Jason a écrit : On Sep 5, 3:53 pm, Peter Otten <__pete...@web.de> wrote: m = gio.File(".").monitor_directory() C = type(m) 'C' will not necessarily be 'gio.FileMonitor' — I think the internals of the GIO methods might further "subclass" it in some way depending on what underlying monitors are

Re: Functions continuing to ru after returning something?

2010-08-31 Thread Bruno Desthuilliers
Peter Otten a écrit : n = 1 def f(): ... global n ... try: ... return n ... finally: ... n += 1 ... The same without a global: def f(_n=[0]): try: return _n[0] finally: _n[0] += 1 But yeps, using a generator would be better. -- ht

Re: palindrome iteration

2010-08-27 Thread Bruno Desthuilliers
Dave Angel a écrit : (snip) or (untested) def is_palindrom(s): s = s.lower() return s == s[::-1] Right, go on, make me feel a bit more stupid :-/ Who's next ? -- http://mail.python.org/mailman/listinfo/python-list

Re: palindrome iteration

2010-08-27 Thread Bruno Desthuilliers
Richard Arts a écrit : Now there is another solution. A palindrom is made of two symetric halves, with (odd len) or without (even len) a single char between the symetric halves, ie : * odd : ABCBA ('AB' + 'C' + 'BA') * even : ABCCBA ('ABC' + 'CBA') So you just have to extract the symetric halve

Re: palindrome iteration

2010-08-27 Thread Bruno Desthuilliers
Baba a écrit : level: beginner the following code looks ok to me but it doesn't work. "doesn't work" is about the most useless description of a problem. Please specify what you expected and what actually happens. I would like some hints as to where my reasoning / thought goes wrong def i_

Re: Iterative vs. Recursive coding

2010-08-26 Thread Bruno Desthuilliers
BartC a écrit : "Steven D'Aprano" wrote in message news:4c6f8edd$0$28653$c3e8...@news.astraweb.com... On Fri, 20 Aug 2010 17:23:23 +0200, Bruno Desthuilliers wrote: I onced worked in a shop (Win32 desktop / accouting applications mainly) where I was the only guy that

Re: Using String Methods In Jump Tables

2010-08-25 Thread Bruno Desthuilliers
Tim Daneliuk a écrit : On 8/19/2010 7:23 PM, Steven D'Aprano wrote: On Thu, 19 Aug 2010 18:27:11 -0500, Tim Daneliuk wrote: Problem: Given tuples in the form (key, string), use 'key' to determine what string method to apply to the string: table = {'l': str.lower, 'u': str.upper} table['u

Re: Iterative vs. Recursive coding

2010-08-24 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : On Fri, 20 Aug 2010 17:23:23 +0200, Bruno Desthuilliers wrote: Steven D'Aprano a écrit : On Thu, 19 Aug 2010 22:00:16 +, Martin Gregorie wrote: Recursion can be quite a trick to get your mind round at first Really? Do people actually find the *c

Re: Iterative vs. Recursive coding

2010-08-20 Thread Bruno Desthuilliers
Michel Claveau - MVP a écrit : Salut ! C'est cela, la solitude du programmeur génial... @-salutations Moi aussi je t'aime, Michel !-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Iterative vs. Recursive coding

2010-08-20 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : On Thu, 19 Aug 2010 22:00:16 +, Martin Gregorie wrote: Recursion can be quite a trick to get your mind round at first Really? Do people actually find the *concept* of recursion to be tricky? I onced worked in a shop (Win32 desktop / accouting applications main

Re: A question to experienced Pythoneers

2010-08-20 Thread Bruno Desthuilliers
Rony a écrit : It looks like I forgot to specify that the product is a totaly new product build from scratch, not an upgrade from an existing product. Still the advice to first find out what went wrong with the previous project is a very sensible one. Technical problems do exist, but from ex

Re: 79 chars or more?

2010-08-20 Thread Bruno Desthuilliers
Stefan Schwarzer a écrit : Hi Neil, On 2010-08-17 14:42, Neil Cerutti wrote: (snip) Looking through my code, the split-up lines almost always include string literals or elimination of meaningless temporary variables, e.g.: self.expiration_date = translate_date(find(response,

Re: Pop return from stack?

2010-08-19 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : Oh my ... I've seen people writing Java in Python, C++ in Python, Perl in Python, even VB in Python, but this is the first time I've meet some one who wants to write assembler in Python :) +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: passing variables as object attributes

2010-08-17 Thread Bruno Desthuilliers
Vikas Mahajan a écrit : On 16 August 2010 19:23, Nitin Pawar wrote: you would need to define a class first with its attiributes and then you may want to initiate the variables by calling the class initilializer Actually I have to dynamically add attributes to a object. I am writing python scr

Re: How do I get number of files in a particular directory.

2010-08-13 Thread Bruno Desthuilliers
blur959 a écrit : Hi, all, Is there a way to get a number of files in a particular directory? I tried using os.walk, os.listdir but they are return me with a list, tuple of the files, etc. But I want it to return a number. Is it possible? len(any_sequence) -- http://mail.python.org/mailman/list

Re: python ide for ubuntu

2010-08-12 Thread Bruno Desthuilliers
geremy condra a écrit : (about eclipse+pydev) Or you could use a text editor and a terminal and spare yourself the agony of dealing with 600MB of Java of questionable quality ;). +1 QOTW -- http://mail.python.org/mailman/listinfo/python-list

Re: Does anyone use Quixote for web developing?

2010-08-12 Thread Bruno Desthuilliers
ph4nut a écrit : Hi all,I am learning Quixote a few days ago,,,and i have no idea about whether there is any Google Group talking about Quixote,so i post this post to check that is Quixote been talking in this group before or can i ask question about Quixote here! From the project's home page:

Re: Using dicts and lists as default arguments of functions

2010-08-09 Thread Bruno Desthuilliers
Johan a écrit : Dear all, Considering this test program: def tst(a={}): Stop here, we already know what will follow !-) And yes, it's one of Python's most (in)famous gotchas : default arguments values are computed only once, at function definition time (that is, when the def statement is e

Re: easy question on parsing python: "is not None"

2010-08-09 Thread Bruno Desthuilliers
Gregory Ewing a écrit : Ethan Furman wrote: Instead of using 'is' use '=='. Maybe not as cute, but definitely more robust! It's also just as efficient if you use strings that resemble identifiers, because they will be interned, Remember : this IS an implementation detail. -- http://mail.p

Re: easy question on parsing python: "is not None"

2010-08-06 Thread Bruno Desthuilliers
Richard D. Moores a écrit : On Thu, Aug 5, 2010 at 16:15, Rhodri James wrote: On Thu, 05 Aug 2010 17:07:53 +0100, wheres pythonmonks wrote: You're not testing for equivalence there, you're testing for identity. "is" and "is not" test whether the two objects concerned are (or are not) the s

Re: assigning variables from list data

2010-08-06 Thread Bruno Desthuilliers
Chris Hare a écrit : I have a database query result (see code below). In PHP, I would have said list(var1,var2,var) = $result Other already answered on the Python equivalent. But there's an IMHO better way, which is to use (if the DB-API connector provides it) a DictCursor, that yields dict

Re: easy question on parsing python: "is not None"

2010-08-06 Thread Bruno Desthuilliers
Roald de Vries a écrit : 'not None' first casts None to a bool, and then applies 'not', so 'x is not None' means 'x is True'. Obviously plain wrong : Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on linux2 Type "help", "copyright", "credits" or "license" for more informat

Re: The untimely dimise of a weak-reference

2010-08-02 Thread Bruno Desthuilliers
Gregory Ewing a écrit : (snip) import weakref class weakmethod(object): def __init__(self, bm): self.ref = weakref.ref(bm.im_self) self.func = bm.im_func def __call__(self, *args, **kwds): obj = self.ref() if obj is None: raise ValueError("Calling dead weak method")

Re: Nice way to cast a homogeneous tuple

2010-07-28 Thread Bruno Desthuilliers
wheres pythonmonks a écrit : Thanks ... I thought int was a type-cast (like in C++) so I assumed I couldn't reference it. Python has no C/C++ like "type-cast". "int" is the builtin integer type, and instanciating an object in Python is done by calling it's type. Remember that in Python, every

Re: hasattr + __getattr__: I think this is Python bug

2010-07-28 Thread Bruno Desthuilliers
Ethan Furman a écrit : Bruno Desthuilliers wrote: Bruno Desthuilliers a écrit : Ethan Furman a écrit : Bruno Desthuilliers wrote: Duncan Booth a écrit : (snip) Or you could create the default as a class attribute from the OP: """ I have a class (FuncDesigner oofun) that h

Re: Why is there no platform independent way of clearing a terminal?

2010-07-27 Thread Bruno Desthuilliers
Grant Edwards a écrit : On 2010-07-27, Bruno Desthuilliers wrote: Daniel Fetchinson a ?crit : (snip) Why was clearing a terminal left out? What you're talking about is a shell, not a terminal (a terminal is a physical device). No, what he's talking about is clearing a term

Re: Why is there no platform independent way of clearing a terminal?

2010-07-27 Thread Bruno Desthuilliers
Daniel Fetchinson a écrit : Hi folks, If I'm only interested in linux and windows I know I can do import os import platform if platform.system( ) == 'Linux': clear = 'clear' else: clear = 'cls' os.system( clear ) or so

Re: hasattr + __getattr__: I think this is Python bug

2010-07-27 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : Ethan Furman a écrit : Bruno Desthuilliers wrote: Duncan Booth a écrit : (snip) Or you could create the default as a class attribute from the OP: """ I have a class (FuncDesigner oofun) that has no attribute "size", but it is overloa

Re: hasattr + __getattr__: I think this is Python bug

2010-07-27 Thread Bruno Desthuilliers
Ethan Furman a écrit : Bruno Desthuilliers wrote: Duncan Booth a écrit : (snip) Or you could create the default as a class attribute from the OP: """ I have a class (FuncDesigner oofun) that has no attribute "size", but it is overloaded in __getattr__, so if someo

Re: python terminology on classes

2010-07-27 Thread Bruno Desthuilliers
Peng Yu a écrit : Hi I'm still kind of confused about the terminology on classes in python. Could you please let me know what the equivalent terms for the following C++ terms? C++ and Python having very different semantics and object models, there's not necessarily a straight one to one mapp

Re: why is this group being spammed?

2010-07-26 Thread Bruno Desthuilliers
be.krul a écrit : Why not moderate this group? This is a hi-traffic group, so it would require a huge team of moderators. -- http://mail.python.org/mailman/listinfo/python-list

Re: hasattr + __getattr__: I think this is Python bug

2010-07-26 Thread Bruno Desthuilliers
Duncan Booth a écrit : Bruno Desthuilliers wrote: If you don't want to create as many Whatever instances as MyClass instances, you can create a single Whatever instance before defining your class: DEFAULT_WHATEVER = Whathever() class MyClass(object): def __init__(self,

Re: hasattr + __getattr__: I think this is Python bug

2010-07-26 Thread Bruno Desthuilliers
dmitrey a écrit : (snip) This doesn't stack with the following issue: sometimes user can write in code "myObject.size = (some integer value)" and then it will be involved in future calculations as ordinary fixed value; if user doesn't supply it, but myObject.size is involved in calculations, the

Re: Only one forum app in Python?

2010-07-10 Thread Bruno Desthuilliers
Gilles Ganault a écrit : > Hello > > I'd like to write a small web app in Python which must include a > forum. > > So I checked the relevant article in Wikipedia, which says that only > one forum app is available for Python: > > http://en.wikipedia.org/wiki/Comparison_of_internet_forum_software_

Re: any issues with long running python apps?

2010-07-10 Thread Bruno Desthuilliers
Les Schaffer a écrit : > i have been asked to guarantee that a proposed Python application will > run continuously under MS Windows for two months time. And i am looking > to know what i don't know. (snip) > but none of this has anything to do with Python itself. i am sure python > servers have b

Re: delegation pattern via descriptor

2010-07-08 Thread Bruno Desthuilliers
kedra marbun a écrit : On Jul 7, 2:46 am, Bruno Desthuilliers wrote: Gregory Ewing a écrit : Bruno Desthuilliers wrote: kedra marbun a écrit : if we limit our discussion to py: why __{get|set|delete}__ don't receive the 'name' & 'class' from __{getattribute|{

Re: delegation pattern via descriptor

2010-07-06 Thread Bruno Desthuilliers
Gregory Ewing a écrit : > Bruno Desthuilliers wrote: >> kedra marbun a écrit : >> >>> if we limit our discussion to py: >>> why __{get|set|delete}__ don't receive the 'name' & 'class' from >>> __{getattribute|{set|del}attr}

Re: delegation pattern via descriptor

2010-07-06 Thread Bruno Desthuilliers
kedra marbun a écrit : On Jul 5, 3:42 pm, Bruno Desthuilliers wrote: kedra marbun a écrit : i'm confused which part that doesn't make sense? this is my 2nd attempt to py, the 1st was on april this year, it was just a month, i'm afraid i haven't got the fundamentals rig

Re: delegation pattern via descriptor

2010-07-05 Thread Bruno Desthuilliers
kedra marbun a écrit : i'm confused which part that doesn't make sense? this is my 2nd attempt to py, the 1st was on april this year, it was just a month, i'm afraid i haven't got the fundamentals right yet. so i'm gonna lay out how i got to this conclusion, CMIIW **explanation of feeling (0) on

Re: delegation pattern via descriptor

2010-07-03 Thread Bruno Desthuilliers
kedra marbun a écrit : > if we limit our discussion to py: > why __{get|set|delete}__ don't receive the 'name' & 'class' from > __{getattribute|{set|del}attr}__ > 'name' is the name that is searched While it would have been technically possible, I fail to imagine any use case for this. -- http:/

Re: loading configuration files that are themselves python

2010-07-03 Thread Bruno Desthuilliers
Matthew Vernon a écrit : > Hi, > > Is there a more idiomatic way of loading in a configuration file > that's python code than: > > _temp=__import__(path,fromlist='cachestrs') > cachestrs=_temp.cachestrs > > ? I mean, that's pretty ugly...Plain "import" doesn't work in this > case because 'path'

Re: Python dynamic attribute creation

2010-07-02 Thread Bruno Desthuilliers
WANG Cong a écrit : On 06/30/10 01:25, Ethan Furman wrote: But if so why setattr() still exists? What is it for if we can do the same thing via assignments? Also, in order to be perfect, Python should accept to add dynamic attributes dynamically, something like PEP 363. That doesn't happen. S

Re: Python dynamic attribute creation

2010-07-02 Thread Bruno Desthuilliers
WANG Cong a écrit : On 07/01/10 23:19, Stephen Hansen wrote: As long as setattr() exists in Python, that will be not so ordinary. :) setattr is perfectly ordinary. If you think setattr() is as ordinary as a trivial assignment, setattr IS a trivial assignment. However, I think setattr(

Re: Ignorance and Google Groups (again)

2010-07-01 Thread Bruno Desthuilliers
D'Arcy J.M. Cain a écrit : On Thu, 01 Jul 2010 14:07:27 +0200 Bruno Desthuilliers wrote: And AFAICT you're wrong. I read and post to c.l.py using my newsreader (so NOT going thru GG), and my personal address is @gmail.com. But... From: Bruno Desthuilliers Sorry, there&#

Re: Python dynamic attribute creation

2010-07-01 Thread Bruno Desthuilliers
Stephen Hansen a écrit : On 6/30/10 10:37 PM, Aahz wrote: In article<4c29ad38$0$26210$426a7...@news.free.fr>, Bruno Desthuilliers wrote: Aahz a écrit : In article<4c285e7c$0$17371$426a7...@news.free.fr>, Bruno Desthuilliers wrote: Aahz a écrit : In article<4c2747

Re: List-type attributes and name strings

2010-07-01 Thread Bruno Desthuilliers
egbert a écrit : Normally you use setattr() if the name of the attribute is in a namestring: setattr(self, namestring, value) But my attributes are lists or dictionaries, and I don't seem to be able to use setattr anymore. Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) [GCC 4.3.3] on

Re: Ignorance and Google Groups (again)

2010-07-01 Thread Bruno Desthuilliers
D'Arcy J.M. Cain a écrit : On Wed, 30 Jun 2010 14:06:05 -0700 Stephen Hansen wrote: Gmail and Google Groups are not one and the same. There's a number of people who subscribe to the list directly, use Gmail, and don't go anywhere near Google Groups. I know that. My filter doesn't catch them

  1   2   3   4   5   6   7   8   9   10   >