Re: Future standard GUI library
Terry Jan Reedy wrote: >> Do you think tkinter is going to be the standard python built-in gui >> solution as long as python exists? > > AT the moment, there is nothing really comparable that is a realistic > candidate to replace tkinter. FLTK? (http://www.fltk.org/index.php) -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Short-circuit Logic
Cameron Simpson wrote: > if s is not None and len(s) > 0: > ... do something with the non-empty string `s` ... > > In this example, None is a sentinel value for "no valid string" and > calling "len(s)" would raise an exception because None doesn't have > a length. obviously in this case an `if s: ...` is more than sufficient :P -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Python error codes and messages location
Fábio Santos wrote: >> This should make life easier for us > http://docs.python.org/3/whatsnew/3.3.html#pep-3151-reworking-the-os-and-io-exception-hierarchy > > Speaking of PEPs and exceptions. When do we get localized exceptions? What do you mean by "localized exceptions"? Please, tell me it's *NOT* a proposal to send the exception message in the locale language! -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Python error codes and messages location
Fábio Santos wrote: >> > > Speaking of PEPs and exceptions. When do we get localized exceptions? >> > >> > What do you mean by "localized exceptions"? >> > >> > Please, tell me it's *NOT* a proposal to send the exception message in >> > the >> > locale language! >> It is. I think I read it mentioned in python-dev or this list. > > Here is what I read. > > http://mail.python.org/pipermail/python-dev/2013-April/125364.html > > It wasn't only about exceptions after all. And it seems like something > that will only happen far into the future. I really hope really far... have you never tried to google a localized error message? :\ -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: PyWart: The problem with "print"
Rick Johnson wrote: > Take your > standard yes/no/cancel dialog, i would expect it to return > True|False|None respectively, you clearly mean True / False / FileNotFound. ( http://thedailywtf.com/Articles/What_Is_Truth_0x3f_.aspx ) -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
a little more explicative error message?
Hi I was writing a decorator and lost half an hour for a stupid bug in my code, but honestly the error the python interpreter returned to me doesn't helped... $ python3 Python 3.3.0 (default, Feb 24 2013, 09:34:27) [GCC 4.7.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from functools import wraps >>> def dec(fun): ... @wraps ... def ret(*args, **kwargs): ... return fun(*args, **kwargs) ... return ret ... >>> @dec ... def fun(): pass ... >>> fun() Traceback (most recent call last): File "", line 1, in TypeError: update_wrapper() missing 1 required positional argument: 'wrapper' >>> $ Soo... at a first glance, no tricks... can you tell where is the error? :D As I said, the error is totally mine, I just forgot to pass the function as parameter to wraps. But... what is "update_wrapper()"? and "wrapper"? There is no useful traceback or something... just... this. Ok, the documentation clearly says: This is a convenience function to simplify applying partial() to update_wrapper(). So, again, shame on me... I just read carefully the doc *after* 20 minutes trying everything else... still... I think should be useful if wraps() intercept this error saying something more explicit about the missing fun parameter... -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
Ed Leafe wrote: > I had read about a developer who switched to using proportional fonts for > coding, and somewhat skeptically, tried it out. After a day or so it > stopped looking strange, and after a week it seemed so much easier to > read. By my (limited) experience with proportional fonts, they can be useful only with something like elastic tabstops[0]. But, as a general rule, I simply found more "squared" to just use a fixed-width font. [0] http://nickgravgaard.com/elastictabstops/ -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: PEP8 79 char max
Joshua Landau wrote: >> By my (limited) experience with proportional fonts, they can be useful >> only with something like elastic tabstops[0]. But, as a general rule, I >> simply found more "squared" to just use a fixed-width font. > Not if you give up on the whole "aligning" thing. and this is one of the reason why I come back to fixed-width -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Safely add a key to a dict only if it does not already exist?
Steven D'Aprano wrote: > I wish to add a key to a dict only if it doesn't already exist, but do it > in a thread-safe manner. > > The naive code is: > > if key not in dict: > dict[key] = value > > > but of course there is a race condition there: it is possible that > another thread may have added the same key between the check and the > store. > > How can I add a key in a thread-safe manner? using locks? import threading lock = threading.Lock() with lock: if key not in dict: dict[key] = value -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Safely add a key to a dict only if it does not already exist?
Chris Rebert wrote: >> How can I add a key in a thread-safe manner? > I'm not entirely sure, but have you investigated dict.setdefault() ? but how setdefault makes sense in this context? It's used to set a default value when you try to retrieve an element from the dict, not when you try to set a new one ... -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Safely add a key to a dict only if it does not already exist?
Peter Otten wrote: How can I add a key in a thread-safe manner? >>> I'm not entirely sure, but have you investigated dict.setdefault() ? >> >> but how setdefault makes sense in this context? It's used to set a >> default value when you try to retrieve an element from the dict, not when >> you try to set a new one ... > > But it also sets the value if the key is not found: yeah, sure, but with a fixed value :) I mean: if the value is not important, why bother at all trying not to override it with an if or a lock or other tecniques? doing d['key'] = 'fixed_value' multiple times in different threads is not a problem in my eyes... -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Safely add a key to a dict only if it does not already exist?
Peter Otten wrote: uhhmm.. I think I misread the example d = {} d.setdefault(1, 2) > 2 d > {1: 2} d.setdefault(1, 3) > 2 d > {1: 2} yeah, sure it can be useful for the OP... -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Increase value in hash table
moonhkt wrote: > Data file > V1 > V2 > V3 > V4 > V4 > V3 > > How to using count number of data ? > > Output > V1 = 1 > V2 = 1 > V3 =2 > V4 = 2 import collections with open(data_file) as f: print(collections.Counter(f.readlines())) it's a start -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Retrieving an object from a set
MRAB wrote: > It turns out that both S & {x} and {x} & S return {x}, not {y}. curious. $ python Python 2.7.3 (default, Jul 3 2012, 19:58:39) [GCC 4.7.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> x = (1,2,3) >>> y = (1,2,3) >>> s = set([y]) >>> (s & set([x])).pop() is y False >>> (set([x]) & s).pop() is y True maybe it's implementation-defined? -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing offset-aware and offset-naive datetimes?
Roy Smith wrote: > I have two datetimes. One is offset-naive. The other is offset-aware, > but I happen to know its offset is 0 (i.e. GMT). How can I compare > these? http://pytz.sourceforge.net/#localized-times-and-date-arithmetic -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: How to compute a delta: the difference between lists of strings
J. Mwebaze wrote: > This is out of curiosity, i know this can be done with python diffllib > module, but been figuring out how to compute the delta, Consider two lists > below. > > s1 = ['e', 'f', 'g', 'A', 'B', 'C', 'D', 'C'] > s2 =['e', 'A', 'B', 'f', 'g', 'C', 'D', 'z'] > > This is the result should be > > [' e', '+ A', '+ B', ' f', ' g', '- A', '- B', ' C', ' D', '- C', '+ > z'] > > ideas on how to approach this.. ? http://en.wikipedia.org/wiki/Longest_common_subsequence_problem -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: GUI toolkits and dynamic table browser widget
Simon Cropper wrote: >>> I would like to create windows with grids (AKA rows and column of a >>> table like excel). Do any of the GUI interfaces have these types of >>> widgets? i have looked but can't find any and I have not stumbled on >>> program that presents data in this way so I can see how they do it. >>> >>> Specifically I would like to run a SQL command and have the returned >>> list passed to a widget with little or no manipulation and that widget >>> present the data, allow the user to scroll through that data and >>> preferably allow edits to occur. These edits could then be passed back >>> via a string to the program for inclusion in a sql-update command. >> Have a look at PyQt [1], specially QTableView [2] and QtSql [3] > That looks very promising... do you understand the licensing though? > > GPL to GPL is obvious but would development of an in-house system be > commercial or GPL licensing? If you're so scared of GPL, you should look at pyside: http://www.pyside.org/docs/pyside/PySide/QtGui/QTableView.html -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Best way to insert sorted in a list
SherjilOzair wrote: > There are basically two ways to go about this. [...] > What has the community to say about this ? What is the best (fastest) > way to insert sorted in a list ? a third way maybe using a SkipList instead of a list on http://infohost.nmt.edu/tcc/help/lang/python/examples/pyskip/ you can find a pure python implementation (but afaik there are many others) -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: dedent 0.5 released
Christian Tismer wrote: > $ python -c """some code""" totally offtopic but... since when bash support python-style triple quote?? Is it another shell?? -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: ESR "Waning of Python" post
Chris Angelico wrote: >> Reference counting was likely a bad idea to begin with. > > Then prove CPython wrong by making a fantastically better > implementation that uses some other form of garbage collection. I'm not talking about the "goodness" of the implemetations, but AFAIK jython and ironpython doesn't have the refcount gb (and they don't even have the GIL...) -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: repeat items in a list
Random832 wrote: > How do you turn ['a', 'c', 'b'] into ['a', 'a', 'a', 'c', 'c', 'c', 'b', > 'b', 'b']? >>> sum([[e]*3 for e in ['a', 'c', 'b']], []) ['a', 'a', 'a', 'c', 'c', 'c', 'b', 'b', 'b'] -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: [OT] C# -- sharp or carp? was Re: Learning Python (or Haskell) makes you a worse programmer
Sven R. Kunze wrote: >>> My question to those who know a bit of C#: what is the state-of-the-art >>> equivalent to >>> >>> "\n".join(foo.description() for foo in mylist >>> if foo.description() != "") > Friend of mine told me something like this: > > String.Join("\n", mylist.Where(foo => > !String.IsNullOrEmpty(foo.description)).Select(foo => foo.description)) I don't know if is "better" or not, but I find more readable using the "sql"-like syntax string.Join("\n", from foo in mylist where !string.IsNullOrEmpty(foo.description()) select foo.description()); which is relatively similar to the python's comprehension. -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: Drowning in a teacup?
Fillmore wrote: > I need to scan a list of strings. If one of the elements matches the > beginning of a search keyword, that element needs to snap to the front > of the list. I know this post regards the function passing, but, on you specific problem, can't you just ... sort the list with a custom key? something like (new list) >>> sorted(['no_a', 'yes_c', 'no_b', 'yes_z', 'no_y', 'yes_x'], ... key=lambda e: not e.startswith('yes')) ['yes_c', 'yes_z', 'yes_x', 'no_a', 'no_b', 'no_y'] or (in place) >>> l = ['no_a', 'yes_c', 'no_b', 'yes_z', 'no_y', 'yes_x'] >>> l.sort(key=lambda e: not e.startswith('yes')) >>> l ['yes_c', 'yes_z', 'yes_x', 'no_a', 'no_b', 'no_y'] -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: Drowning in a teacup?
Michael Selik wrote: >> > I need to scan a list of strings. If one of the elements matches the >> > beginning of a search keyword, that element needs to snap to the front >> > of the list. >> >> I know this post regards the function passing, but, on you specific >> problem, >> can't you just ... sort the list with a custom key? > > If the number of matches is small relative to the size of the list, I'd > expect the sort would be slower than most of the other suggestions. umm... I take the liberty to set up a little test $ cat test_sort_prefix.py #!/usr/bin/env python3 from sys import argv from timeit import timeit def sort_in_place(l): def key(e): return not e.startswith('yes') l.sort(key=key) def original_solution(mylist): for i in range(len(mylist)): if(mylist[i].startswith('yes')): mylist[:] = [mylist[i]] + mylist[:i] + mylist[i+1:] def main(): if argv[1] == 'sort_in_place': f = sort_in_place elif argv[1] == 'original_solution': f = original_solution else: raise Exception() nomatches = int(argv[2]) matches = int(argv[3]) l = ["no_" for _ in range(nomatches)] + ["yes_" for _ in range(matches)] print(timeit("f(l)", number=100, globals={"f": f, "l": l})) if __name__ == '__main__': main() $ ./test_sort_prefix.py sort_in_place 100 3 33.260575089996564 $ ./test_sort_prefix.py original_solution 100 3 35.93009542999789 $ in my tests there is no sensible difference between the two solutions... and the number of matches is risible :) -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: how to setup for localhost:8000
Chris Angelico wrote: >> Just a note, some browsers will try to resolve this as www.localhost.com >> - try http://127.0.0.1:8000 . > > Huh? Why should the name 'localhost' get a dot com added? ask browser vendors... -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: Highlighting program variables instead of keywords?
Skip Montanaro wrote: > My son sent me a link to an essay about highlighting program data instead > of keywords: > > https://medium.com/p/3a6db2743a1e/ > > I think this might have value, especially if to could bounce back and > forth between both schemes. Is anyone aware of tools like this for Python? AFAIK kdevelop support this. http://kdevelop.org/sites/kdevelop.org/files/photos/kdev_python_1.png -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: (test) ? a:b
Dennis Lee Bieber wrote: >> x = [f(), g()] [cond] >> >>the latter evaluates both f() and g() instead of just one. Apart from >>being inefficient, it can have unintended side-effects. > > Ah, but what would > > x = [f, g][cond]() > > produce? headache -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: How about some syntactic sugar for " __name__ == '__main__' "?
Steven D'Aprano wrote: > Chris Kaynor wrote: > >> I was thinking along the lines of replacing: >> >> if __name__ == "__main__": >> <<>> >> >> with >> >> @main >> def myFunction() >> <<<> >> >> Both blocks of code will be called at the same time. > > > You can't guarantee that, because you cannot tell ahead of time when the > "if __name__" statement will be run. It is *usually* at the end of the > file, but that's just the normal useful convention, it is not a hard > requirement. sure you can: simply the main decorator is just something like def main(myMainFunction): if myMainFunction.__module__ == '__main__': myMainFunction() return myMainFunction -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: How about some syntactic sugar for " __name__ == '__main__' "?
Ian Kelly wrote: >> def main(func): >> if func.__module__ == "__main__": >> func() >> return func # The return could be omitted to block the function from >> being manually called after import. >> >> Just decorate the "main" function of the script with that, and it will be >> automatically called when ran as a script, but not when imported as a >> module. > > This calls it at the wrong time, though. Typically the way this idiom > is used is that you define everything you need (functions, classes, > etc.) within the main script, and then you call the main function. > This would call the main function at the time it's defined, when other > things in the main script may not have been defined yet. One could > place the main function last, but it would be preferable not to be > forced. for the "right time" you can choose to spin a thread and wait to the end of the load of the module something like from threading import Thread, current_thread def run_func(func, module_thread): module_thread.join() func() def main(func): if func.__module__ == '__main__': Thread(target=run_func, args=[func, current_thread()]).start() return func -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: learning to use iterators
Seb wrote: def n_grams(a, n): > ... z = (islice(a, i, None) for i in range(n)) > ... return zip(*z) > ... > > I'm impressed at how succinctly this islice helps to build a list of > tuples with indices for all the required windows. If you want it succinctly, there is this variation on the theme: n_grams = lambda a, n: zip(*(a[i:] for i in range(n))) -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: dunder-docs (was Python is DOOMED! Again!)
Steven D'Aprano wrote: > Checking the REPL first would have revealed that [].__dir__ raises > AttributeError. In other words, lists don't have a __dir__ method. ? Python 3.4.2 (default, Nov 29 2014, 00:45:45) [GCC 4.8.3] on linux Type "help", "copyright", "credits" or "license" for more information. >>> [].__dir__() ['sort', '__contains__', '__init__', '__ge__', 'count', '__class__', '__format__', '__mul__', 'index', '__rmul__', '__hash__', '__iter__', 'clear', '__subclasshook__', '__getitem__', 'reverse', 'append', '__ne__', 'pop', '__reduce__', '__add__', 'extend', '__gt__', '__sizeof__', '__setattr__', '__imul__', '__dir__', '__le__', 'insert', '__repr__', '__str__', '__getattribute__', '__len__', '__lt__', 'remove', '__new__', '__reduce_ex__', 'copy', '__reversed__', '__delattr__', '__eq__', '__setitem__', '__iadd__', '__doc__', '__delitem__'] >>> -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: pymongo and attribute dictionaries
Steven D'Aprano wrote: >> This just does not roll of the fingers well. Too many “reach for modifier >> keys” in a row. > > *One* modifier key in a row is too many? > > s o m e SHIFT D o c [ ' SHIFT _ i d ' ] I'm not OP, but as side note... not everyone has "[" as a direct character on the keyboard. I need to press "AltGr" + "è" (and "AltGr" + "+" to get "]"), so I can feel the OP lamenting :) s o m e SHIFT D o c ALTGR è ' SHIFT - i d ' ALTRG + -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: Does Python 'enable' poke and hope programming?
CM wrote: > Basically this amounts to: with an interpreted language (so of course > this is not really just about Python--I just think in terms of Python), > it's easier to be mentally lazy. But, ironically, being lazy winds up > creating *way* more work ultimately, since one winds up programming in > this terribly inefficient way, and progress proceeds at an, at times, > evolutionary (slow!) pace. you have found repl are cool :D -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Can someone suggest better resources for learning sqlite3? I wanted to use the Python library but I don't know sql.
Aseem Bansal wrote: > I have tried sql.learncodethehardway but it isn't complete yet. I tired > looking on stackoverflow's sql tag also but nothing much there. Can > someone suggest me better resources for learning sql/sqlite3? a start is the sqlite homepage: http://www.sqlite.org/docs.html -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: new to While statements
Joshua Landau wrote: > while "asking for reponse": > while "adventuring": that's a funny way to say `while True:`... -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: new to While statements
Dan Sommers wrote: >>> while "asking for reponse": >> >>> while "adventuring": >> >> that's a funny way to say `while True:`... > > Funny, perhaps, the first time you see it, but way more informative than > the other way to the next one who comes along and reads it. While I understand that it's syntactically and semantically correct, my nose still doesn't like it. It's not that's just not common... I just think it's a mishmash... it's not a "rule" thing, more a "feeling wrong" one. Maybe it's better if I try to explain in another way... My first instinct about it it's to think why the author choose this way to talk to the reader. This message it's clearly meant to be read by another programmer, not by the user. But in my mind it should be a comment. In my mind code explain "what" is happening, comment say "why". (Sometimes talking to my colleagues we say comment is a way to ask to forgiveness for a particular obscure code, as in "sorry, I needed to flip-this and flop-that for such-and-such reason") Following this reasoning, I will found more readable something like # asking for response while True: ... that while 'asking for response': ... because in the latter case the "why" and the "how" are mixed. It's like you're talking with the interpreter, but the message is for the programmer.. I hope I explained myself... -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Language design
Chris Angelico wrote: > Making line breaks significant usually throws people. It took my > players a lot of time and hints to figure this out: > http://rosuav.com/1/?id=969 fukin' Gaston! -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: Functional Programming and python
rusi wrote: > [Not everything said there is correct; eg python supports currying better > [than haskell which is surprising considering that Haskell's surname is > [Curry!] AFAIK python does not support currying at all (if not via some decorators or something like that). Instead every function in haskell implicitly support currying... so... how does "no support" is better than "full support"? -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: Obfuscated factorial
Steven D'Aprano wrote: > Just for fun: [...] you miss a FactoryFactory and a couple of *Manager. Oh, and it should be xml-config-driven. -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: Obfuscated factorial
Joshua Landau wrote: > Python already supports the factorial operator, -ⵘ. why use ⵘ (TIFINAGH LETTER AYER YAGH) when you can have the BANG? 방 (HANGUL SYLLABLE BANG) > You just have to > import it. > > # Import statement > ⵘ = type("",(),{"__rsub__":lambda s,n:(lambda f,n:f(f,n))(lambda > f,z:round((2.5066282746310002*(z+0j+7.5)**(z+0.5)*2.718281828459045**(- z-7.5)*(0.80993+676.5203681218851/(z+1)-1259.1392167224028/(z+2)+771.32342877765313/(z+3)-176.61502916214059/(z+4)+12.507343278686905/(z+5)-0.13857109526572012/(z+6)+9.9843695780195716e-6/(z+7)+1.5056327351493116e-7/(z+8))).real)if > z>=0.5 else > 3.141592653589793/(__import__("math").sin(3.141592653589793*z)*f(f,1- z)),n)})() I'm really, really impressed! -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: should "self" be changed?
Mark Lawrence wrote: >> def __init__(ስ): >> ስ.dummy = None > Apart from breaking all the tools that rely on "self" being spelt "self" > this looks like an excellent idea. too bad for the tools: using the name "self" is just a convention, not a rule. -- By ZeD -- https://mail.python.org/mailman/listinfo/python-list
Re: Python Newbie
piterrr.dolin...@gmail.com wrote: > You see, Javascript, for one, behaves the same way as Python (no variable > declaration) but JS has curly braces and you know the variable you have > just used is limited in scope to the code within the { }. With Python, you > have to search the whole file. I don't know if you know javascript, but I think your experience with it is limited, as you listed two of of the many common pitfalls of javascript: javascript has optional variable declaration, but if you don't declare a variable (such as a local variable in a function) it binds itself in the global scope; in c/c++/c#/java... curly braces define a new scope, in javascript no. if you do in javascript function foo() { if (some condition) { a = 'something'; } alert(a); } the moment you call the foo() function (and some condition is true), a global variable "a" is created. (this time you *really* need to search not the whole .js file, but the whole project, as there is no "file-level" globals in javascript) if you instead use the 'var' keyword to define explicitly a local variable function foo() { if (some condition) { var a = 'something'; } alert(a); } while you don't create a global variable, the "a" variable is still accessible outside the "if" braces. this is the reason most javascript linters (most notably jslint) force the first statement of every function to be the definition of all function variables. by this point of view, python and javascript have the same philosophy, but at least python doesn't allow implicit global variable definition -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: An error when i switched from python v2.6.6 => v3.2.3
Νίκος Γκρ33κ wrote: >> -c ''; rm -rf /; oops.py > > Yes its being pulled by http request! > > But please try to do it, i dont think it will work! try yourself and tell us what happened -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: pyqt4 & qt license
D. Xenakis wrote: > Can someone develop a closed source but NON-commercial software, by using > PyQT4 GPL license? no, by definition of GPL: if you are using a GPL library, you must distribute your software as GPL. (the GPL does not care about commercial / non commercial) http://www.gnu.org/licenses/gpl-faq.html#IfLibraryIsGPL -- ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: vb2py status?
axtens wrote: > So is vb2py dead? If not, any idea when it'll support python 3? I don't know this vb2py, but you can do a 2 pass conversion [vb] -> (vb2py) -> [py2] -> (2to3) -> [py3] -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: vb2py status?
Giampaolo Rodola' wrote: >> > So is vb2py dead? If not, any idea when it'll support python 3? >> I don't know this vb2py, but you can do a 2 pass conversion >> [vb] -> (vb2py) -> [py2] -> (2to3) -> [py3] > ...and presumibly get something which doesn't work at all. =) why? AFAIK there aren't problems into the 2to3 phase I don't think the resulted python code would be the best one, but at least it should work... -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Removing None objects from a sequence
Filip Gruszczyński wrote: > I checked itertools, but the only thing that > seemed ok, was ifilter - this requires seperate function though, so > doesn't seem too short. is this too much long? >>> from itertools import ifilter >>> for element in ifilter(lambda x: x is not None, [0,1,2,None,3,None,4]): ... print element ... 0 1 2 3 4 >>> -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Why is lambda allowed as a key in a dict?
MRAB wrote: > >>> (lambda arg: arg) == (lambda arg: arg) > False curious... I somehow thinked that, whereas >>> (lambda: 0) is (lambda: 0) should be False (obviously) >>> (lambda: 0) == (lambda: 0) could be True... maybe because `{} == {} and {} is not {}` (also for []) -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: How complex is complex?
Tim Roberts wrote: > bearophileh...@lycos.com wrote: >> >>In Python 3 those lines become shorter: >> >>for k, v in a.items(): >>{k: v+1 for k, v in a.items()} > > That's a syntax I have not seen in the 2-to-3 difference docs, so I'm not > familiar with it. How does that cause "a" to be updated? I think he would write >>> a = { 'a': 4, 'c': 6, 'b': 5 } >>> a = { k:v+1 for k, v in a.items() } >>> a {'a': 5, 'c': 7, 'b': 6} -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading 3 objects at a time from list
Matteo wrote: > it works and I like slices, but I was wondering if there was another > way of doing the same thing, maybe reading the numbers in groups of > arbitrary length n... from http://docs.python.org/library/itertools.html#recipes def grouper(n, iterable, fillvalue=None): "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx" args = [iter(iterable)] * n return izip_longest(fillvalue=fillvalue, *args) and it's *damned* fast! -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Man Bites Python
Mikael Olofsson wrote: > I don't think the guy in question finds it that funny. I don't think the python in question finds it that funny. -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list
problem with pylint + PyQt4
I'm having probles using pylint on a PyQt4 application. $ cat TEST_pylint.py import PyQt4.QtCore from PyQt4.QtGui import QApplication $ python TEST_pylint.py # no import errors $ pylint --disable-msg=C0103 --disable-msg=C0111 --disable-msg=W0611 \ > TEST_pylint.py * Module TEST_pylint E: 1: No name 'QtCore' in module 'PyQt4' E: 2: No name 'QtGui' in module 'PyQt4' [...cut...] $ pylint --version pylint 0.15.0, astng 0.17.3, common 0.35.0 Python 2.6 (r26:66714, Feb 3 2009, 20:52:03) [GCC 4.3.2 [gcc-4_3-branch revision 141291]] $ rpm -q python-qt4 python-qt4-4.5.snapshot.20090507-9.3 why pylint can't find the PyQt4 submodules? -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: how can i check whether a variable is iterable in my code?
satoru wrote: > hi, all > i want to check if a variable is iterable like a list, how can i > implement this? untested def is_iterable(param): try: iter(param) except TypeError: return False else: return True -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list
Re: Perl's @foo[3,7,1,-1] ?
Jack Diederich wrote: > the square brackets always expect an int or a slice. true only for lists :) In [1]: mydict = {} In [2]: mydict[1,2,3] = 'hi' In [3]: print mydict[1,2,3] --> print(mydict[1,2,3]) hi -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list