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:
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
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
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 mention
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-lis
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 i
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, th
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 i
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 hav
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
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
>> yo
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
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/mai
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 & se
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-l
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
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
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/py
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
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 ironp
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
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", m
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 cust
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 ... s
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
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 P
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/m
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 c
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
>> a
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 o
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 informa
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 keyb
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 programmin
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
--
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
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 und
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
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
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
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
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.pyt
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 d
Νίκος Γκρ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
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/li
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
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 probl
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,Non
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://
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?
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,
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
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
**
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
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
54 matches
Mail list logo