On Thu, Jul 26, 2012 at 11:01 AM, Dennis Lee Bieber
wrote:
> On Thu, 26 Jul 2012 19:42:11 +1000, Chris Angelico
> declaimed the following in gmane.comp.python.general:
>
>
> > Well, if/while/for could be functions. So could with, probably. Now,
> > def would be a little tricky...
> >
> An
On Tue, Jul 31, 2012 at 1:21 PM, Terry Reedy wrote:
> Another example: KeyError and IndexError are both subscript errors, but
> there is no SubscriptError superclass, even though both work thru the same
> mechanism -- __getitem__. The reason is that there is no need for one. In
> 'x[y]', x is us
On Mon, Aug 6, 2012 at 12:50 PM, Mok-Kong Shen wrote:
> I ran the following code:
>
> def xx(nlist):
> print("begin: ",nlist)
> nlist+=[999]
>
This is modifying the list in-place - the actual object is being changed to
append 999. This can happen because lists are mutable data types in Python
t; timeit.timeit('for i in d.iteritems(): pass',
>>> 'd=dict.fromkeys(range(1000))')
19.922474218828711
>>> timeit.timeit('for i in d: v=d[i]', 'd=dict.fromkeys(range(1000))')
31.00760415282
Chris
On Thu, Aug 9, 2012 at 2:49 PM, Chris K
On Thu, Aug 9, 2012 at 2:34 PM, Roman Vashkevich wrote:
>
> Actually, they are different.
> Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred
> thousand entries, and you will feel the difference.
> Dict uses hashing to get a value from the dict and this is why it's O(1).
>
Us
On Thu, Aug 9, 2012 at 3:26 PM, Dave Angel wrote:
> On 08/09/2012 06:03 PM, Andrew Cooper wrote:
>> On 09/08/2012 22:34, Roman Vashkevich wrote:
>>> Actually, they are different.
>>> Put a dict.{iter}items() in an O(k^N) algorithm and make it a hundred
>>> thousand entries, and you will feel the
Reading your post, I do not see for sure what your actual issue is, so
I am taking my best guess: that the file does not contain as much data
as would be expected.
On Wed, Aug 22, 2012 at 8:38 AM, William R. Wing (Bill Wing)
wrote:
> In the middle of a longer program that reads and plots data fro
On Fri, Aug 24, 2012 at 12:43 PM, Willem Krayenhoff wrote:
> Any idea why print isn't working here?
>
> I tried restarting my Command prompt. Also, print doesn't work inside a
> class.
>
> [image: Inline image 2]
>
In Python 3, print was made into a function rather than a statement for
various r
On Mon, Sep 24, 2012 at 2:49 PM, Dave Angel wrote:
>
> And what approach would you use for positioning relative to
> end-of-file? That's currently done with an optional second parameter to
> seek() method.
>
I'm not advocating for or against the idea, but that could be handled
the same way index
On Mon, Sep 24, 2012 at 3:37 PM, Ian Kelly wrote:
> On Mon, Sep 24, 2012 at 4:14 PM, Chris Angelico wrote:
>> file.pos = 42 # Okay, you're at position 42
>> file.pos -= 10 # That should put you at position 32
>> foo = file.pos # Presumably foo is the integer 32
>> file.pos -= 100 # What should th
On Mon, Oct 8, 2012 at 12:28 PM, wrote:
> What's the best way to accomplish this? Am I over-complicating it? My
> gut feeling is there is a better way than the following:
>
> >>> import itertools
> >>> x = [1, 2, 3]
> >>> y = list(itertools.chain.from_iterable(('insertme', x[i]) for i in
> rang
On Thu, Oct 18, 2012 at 9:47 AM, Dave Angel wrote:
> On 10/18/2012 12:26 PM, Chris Angelico wrote:
> > On Fri, Oct 19, 2012 at 3:16 AM, Evan Driscoll
> wrote:
> >>Python isn't as bad as C++ though (my main other language), where
> >>80 characters can go by *very* quickly.
> >>
> >> 2. Ba
On Fri, Oct 19, 2012 at 12:03 PM, Pradipto Banerjee
wrote:
>
> Thanks, I tried that. Still got MemoryError, but at least this time python
> tried to use the physical memory. What I noticed is that before it gave me
> the error it used up to 1.5GB (of the 2.23 GB originally showed as available)
On Mon, Oct 29, 2012 at 3:30 PM, Steven D'Aprano
wrote:
> On Mon, 29 Oct 2012 17:05:07 +, andrea crotti wrote:
>
>> I meant how do I create new immutables classes myself, I guess that's
>> possible writing C extensions but I don't see in pure Python..
>
> Well, you can't *quite* make a truly i
On Mon, Oct 29, 2012 at 11:00 AM, Andrew Robinson
wrote:
>
> Let's look at the source code rather than the web notes -- the source must
> be the true answer anyhow.
>
> I downloaded the source code for python 3.3.0, as the tbz;
> In the directory "Python-3.3.0/Python", look at Python-ast.c, line 2
One option would be using a hash. Python's built-in hash, a 32-bit
CRC, 128-bit MD5, 256-bit SHA or one of the many others that exist,
depending on the needs. Higher bit counts will reduce the odds of
accidental collisions; cryptographically secure ones if outside
attacks matter. In such a case, yo
On Thu, Nov 15, 2012 at 8:04 AM, Kevin Gullikson
wrote:
> Hi all,
>
> I am trying to make a dictionary of functions, where each entry in the
> dictionary is the same function with a few of the parameters set to specific
> parameters. My actual use is pretty complicated, but I managed to boil down
On Mon, Dec 3, 2012 at 11:58 AM, wrote:
> Dear Group,
>
> I have a tuple of list as,
>
> tup_list=[(1,2), (3,4)]
> Now if I want to covert as a simple list,
>
> list=[1,2,3,4]
>
> how may I do that?
>
> If any one can kindly suggest? Googling didn't help much.
If you know they are always exactly
On Wed, Dec 5, 2012 at 10:50 AM, Olivier Scalbert <
[email protected]> wrote:
> Hi all !
>
> I have a problem that is not easy to explained, so I have tried to reduce
> it a lot.
>
> We are using a framework, that we can not modify.
>
> in framework.py:
> def do(something):
>'''
>
On Wed, Dec 5, 2012 at 12:41 PM, 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:
>>>
>>> I think this should even be considered a bug, not just a missing
>>> optimization. Consider:
>>>
>>
>> This is definitely a bug
Chris
On Wed, Dec 19, 2012 at 7:24 AM, loïc Lauréote wrote:
> Thank for your answer,
>
> I found something allowing to avoid loops.
> I use operator overloading.
>
>
> import math
>
> class Vector:
> def __init__(self, x=0, y=0):
> self.x=x
> self.y=y
> def __eq__(self,
On Wed, Dec 19, 2012 at 4:38 AM, Vlastimil Brom wrote:
> 2012/12/19 loïc Lauréote :
> hi,
> I
> have a question,
> is there a tool to calculate on list ?
>
> something like :
>
> >a= [1,1,1,1]
> >b = [5,9,8,4]
> >c = a+b*a
> >print c
> >[6,10,9,5]
>
> Thx
>
> ==
>
> Hi,
> for such simpler cas
On Sat, Jan 12, 2013 at 5:30 AM, Szabolcs Blága wrote:
> Dear All,
>
> I have an idea that the Ellipsis object could be used in function calls.
> The "..." syntax should automagically turn into an Ellipsis positional
> argument.
>
> def f(*args):
> ext_args = []
> for i, a in enumerate(args):
On Mon, Jan 14, 2013 at 1:28 PM, Chris Angelico wrote:
> On Tue, Jan 15, 2013 at 6:48 AM, wrote:
> > I'd like to develop a small debugging tool for python programs.In
> Dynamic Slicing How can I find the variables that are accessed in a
> statement? And find the type of access (read or write) f
On Wed, Jan 25, 2012 at 3:23 PM, Rick Johnson
wrote:
> On Jan 25, 3:45 pm, Ian Kelly wrote:
> > On Wed, Jan 25, 2012 at 1:14 PM, Rick Johnson
> > In all seriousness, the idea that "very" and "somewhat" are somehow
> > better in this context than "pretty" just because "pretty" has another
> > mean
On Wed, Feb 1, 2012 at 9:11 AM, Olive wrote:
> I am learning python and maybe this is obvious but I have not been able
> to see a solution. What I would like to do is to be able to execute a
> function within the namespace I would have obtained with from
> import *
>
> For example if I write:
>
On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote:
> hmmm, okay.
>
> So how would you round UP always? Say the number is 3219, so you want
> 3300 returned.
>
You may want to look into the mathematical floor and ceiling functions[1].
Python exposes them in the math module as floor and ceil[2].
[1] ht
On Thu, Feb 9, 2012 at 5:40 PM, Chris Kaynor wrote:
> On Thu, Feb 9, 2012 at 5:23 PM, noydb wrote:
>
>> hmmm, okay.
>>
>> So how would you round UP always? Say the number is 3219, so you want
>> 3300 returned.
>>
>
> You may want to look into the
On Thu, Feb 23, 2012 at 2:22 PM, Amirouche Boubekki <
[email protected]> wrote:
>
>
> 2012/2/23 Manish Sharma
>
>> Hi I am new to python language. On my first day, somebody told me that
>> if any python script file is opened with any editor except python
>> editor, the file is corrupte
On Tue, Feb 28, 2012 at 1:04 PM, Craig Yoshioka wrote:
>
> I see that there was previously a PEP to allow the with statement to skip the
> enclosing block... this was shot down, and I'm trying to think of the most
> elegant alternative.
> The best I've found is to abuse the for notation:
>
> for
On Wed, Mar 21, 2012 at 1:34 PM, Chris Rebert wrote:
>
> On Wed, Mar 21, 2012 at 12:30 PM, John Gordon wrote:
> > I'm writing an application that interacts with ldap, and I'm looking
> > for advice on how to handle the connection. Specifically, how to
> > close the ldap connection when the appli
On Tue, Mar 27, 2012 at 3:27 PM, Michael Poeltl
wrote:
> hi,
>
> can anybody tell why this 'little stupid *thing* of code' let's python-3.2.2,
> 2.6.X or python 2.7.2 segfault?
>
>>> def get_steps2(pos=0, steps=0):
> ... if steps == 0:
> ... pos = random.randint(-1,1)
> ... if pos
On Wed, Apr 25, 2012 at 1:05 PM, Frank Miles wrote:
> I have an exceedingly simple function that does a "named import".
> It works perfectly for one file "r"- and fails for the second "x".
>
> If I reverse the order of being called, it is still "x" that fails,
> and "r" still succeeds.
>
> os.acc
On Thu, Apr 26, 2012 at 10:02 AM, Roy Smith wrote:
>
> I'm not seriously suggesting this as a language addition, just an interesting
> idea to simplify some code I'm writing now:
>
> x = [a for a in iterable while a]
>
> which equates to:
>
> x = []
> for a in iterable:
> if not a:
> br
On Wed, May 2, 2012 at 12:51 PM, J. Mwebaze wrote:
> I have multiple objects, where any of them can serve my purpose.. However
> some objects might not have some dependencies. I can not tell before hand if
> the all the dependencies exsit. What i want to is begin processing from the
> 1st object,
On Wed, May 2, 2012 at 1:12 PM, Prasad, Ramit wrote:
>> > I have multiple objects, where any of them can serve my purpose..
>> However
>> > some objects might not have some dependencies. I can not tell before
>> hand if
>> > the all the dependencies exsit. What i want to is begin processing from
>
On Sun, May 13, 2012 at 12:11 PM, Bob Grommes wrote:
> Noob alert: writing my first Python class library.
>
> I have a straightforward class called Utility that lives in Utility.py.
>
> I'm trying to get a handle on best practices for fleshing out a library. As
> such, I've done the following fo
On Wed, May 23, 2012 at 12:42 PM, Dave Angel wrote:
> On 05/23/2012 03:13 PM, Emile van Sebille wrote:
>> A design decision -- there's currently a mix of methods that return
>> themselves and not. Mostly is appears to me that mutables modify in
>> place without returning self and immutables retur
I'm making the presumption that you are using Python 2.x in my notes.
On Thu, Jun 2, 2011 at 3:07 PM, Keir Rice wrote:
> Hi All,
>
> The following function was showing up in my profiles as a large bottle
> neck:
>
> # Slow version
> def RMSBand(self, histogram):
>"""Calculates the root-m
On Jun 18, 2011, at 9:26, John Salerno wrote:
> Whew, thanks for all the responses! I will think about it carefully
> and decide on a way. I was leaning toward simply assigning the health,
> resource, etc. variables in the __init__ method, like this:
>
> def __init__(self, name):
>self.name
You could probably implement something like this using generators and the
send method (note the example is untested and intended for 2.6: I lack
Python on this machine):
def gen(list_):
for i, v in enumerate(list_):
list_[i] = yield v
def execute():
data = range(10)
iterator = gen(data)
On Mon, Jul 11, 2011 at 8:37 PM, Xah Lee wrote:
>
> it's funny, in all these supposedly modern high-level langs, they
> don't provide even simple list manipulation functions such as union,
> intersection, and the like. Not in perl, not in python, not in lisps.
> (sure, lib exists, but it's a ride
On Mon, Jul 25, 2011 at 8:36 AM, Steven W. Orr wrote:
> I have been doing a lot of reading. I'm starting to get it. I think it's
> really cool as well as dangerous, but I plan on being respectful of the
> construct. I found a web page that I found quite readable.
>
> http://cleverdevil.org/**comp
They are actually quite easy to get to. help() on both the class or instance
produces the docstring, and __doc__ on the property as accessed from the
class produces the docstring.
>>> class Test(object):
... @property
... def fred(self):
... """*This is a docstring.*"""
...
You can using metaclasses (untested):
>>>class MyMetaClass(type):
>>>def __iter__(self):
>>>return [1, 2, 3, 4]
>>>class MyClass(object):
>>>__metaclass__ = MyMetaClass
>>>for value in MyClass:
>>>print value
1
2
3
4
Chris
On Tue, Aug 9, 2011 at 2:43 PM, Gelonida N wrote:
On Fri, Aug 12, 2011 at 1:09 PM, Chris Angelico wrote:
> On Fri, Aug 12, 2011 at 6:57 PM, rantingrick
> wrote:
> > I'm glad you brought this up! How about this instead:
> >
> >a = x + y * z
> >
> > ...where the calculation is NOT subject to operator precedence? I
> > always hated using paren
On Fri, Aug 12, 2011 at 1:47 PM, MrPink wrote:
> Boy, that was a lot more elegant that I would have thought.
> Though hard for a greenhorn like me to really understand how the
> assignment are working, etc.
>
> Anyway, what are these kind of statement call so that I can read up
> more on this?
>
On Tue, Aug 16, 2011 at 6:02 PM, Tim Chase
wrote:
> On 08/16/2011 07:33 PM, John Gordon wrote:
>>
>> I stand by my assertion that the phrase "I used to do X" carries the
>> meaning that you have done X in the past but DO NOT INTEND to do so
>> in the future.
>
> I'd tweak the meaning to be somethi
On Mon, Mar 7, 2011 at 8:38 AM, Rogerio Luz wrote:
> Hi All
>
> I'd like to pickle an object instance with all values. So I
> instanciate myClass and set some values including a list with more
> values (in the __init__), then dump to file. I realized that the
> pickled object don't saved my new li
instances of MyClass will share
the same list.
# Untested
>> a = MyClass()
>> print a.lista
['default', 1, 2, 3, 4, 5, 6, 7, 8, 9]
>> a = MyClass()
>> print a.lista
['default', 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]
To get around this, you
On Fri, May 20, 2011 at 9:20 AM, Chris Angelico wrote:
> On Sat, May 21, 2011 at 1:50 AM, MRAB wrote:
> > [snip]
> > Is this strictly true? I thought that the hash value, an integer, is
> > moduloed (Is that how you spell it? Looks weird!) with the number of
> > array elements to give an index i
On Tue, May 31, 2011 at 9:16 AM, Ian Kelly wrote:
> On Tue, May 31, 2011 at 1:38 AM, Daniel Kluev wrote:
> > @decorator.decorator
> > def copy_args(f, *args, **kw):
> >nargs = []
> >for arg in args:
> >nargs.append(copy.deepcopy(arg))
> >nkw = {}
> >for k,v in kw.iteritem
basestring, str, unicode, or bytes
might allow some oddness and possibly slightly worse performance.
Chris
On Tue, May 31, 2011 at 10:10 AM, Ian Kelly wrote:
> On Tue, May 31, 2011 at 10:34 AM, Chris Kaynor
> wrote:
> > Is there any reason not to simplify this to:
> &g
On Fri, Aug 19, 2016 at 12:00 PM, Larry Martell
wrote:
> On Fri, Aug 19, 2016 at 1:24 PM, Chris Angelico wrote:
> > On Sat, Aug 20, 2016 at 3:10 AM, Larry Martell
> wrote:
> >> I have some python code (part of a django app) that processes a
> >> request that contains a png file. The request is
On Wed, Sep 14, 2016 at 1:19 PM, wrote:
> It is so blantantly obvious that the world is not flat I find this
> discussion flabbergasting. Anybody who has tried to take any form of
> vehicle up, or probably more dangerously down, any form of hill knows
> that. As for the raving lunatics who make
On Tue, Sep 20, 2016 at 3:59 PM, Chris Angelico wrote:
> On Wed, Sep 21, 2016 at 8:50 AM, Irmen de Jong
> wrote:
> >> Dunno if it's the cause or not, but you're running a 32-bit PyPy on a
> >> 64-bit Windows. I could well imagine that that has some odd
> >> significance.
> >>
> >> ChrisA
> >
> >
Here is a slight variation of Chris A's code that does not require
more than a single look-ahead per generator. It may be better
depending on the exact data passed in.
Chris A's version will store all of the items for each output that
have a matching key, which, depending on the expected data, cou
On Mon, Nov 21, 2016 at 3:43 PM, John Gordon wrote:
> In Fillmore
> writes:
>
>
>> Question for experts: is there a way to refactor this so that data may
>> be filled/written/released as the scripts go and avoid the problem?
>> code below.
>
> That depends on how the data will be read. Here is
On Wed, Nov 23, 2016 at 11:17 AM, Thomas Grops via Python-list
wrote:
> I need a way of generating a random number but there is a catch:
>
> I don't want to include certain numbers, is this possible?
>
> random.randint(1,100) works as it will randomly pick numbers between 1 and
> 100 but say i do
On Wed, Nov 30, 2016 at 9:34 AM, duncan smith wrote:
> Hello,
> I have had an issue with some code for a while now, and I have not
> been able to solve it. I use the subprocess module to invoke dot
> (Graphviz) to generate a file. But if I do this repeatedly I end up with
> an error. The fol
On Wed, Nov 30, 2016 at 10:58 AM, Chris Angelico wrote:
> On Thu, Dec 1, 2016 at 5:54 AM, Terry Reedy wrote:
>> On 11/30/2016 7:53 AM, Chris Angelico wrote:
>>
>>> I also think that everyone should spend some time writing
>>> multithreaded code before switching to asyncio. It'll give you a
>>> be
On Wed, Nov 30, 2016 at 4:12 PM, duncan smith wrote:
> On 30/11/16 17:57, Chris Angelico wrote:
>> On Thu, Dec 1, 2016 at 4:34 AM, duncan smith wrote:
>>>
>>> def _execute(command):
>>> # shell=True security hazard?
>>> p = subprocess.Popen(command, shell=True, stdin=subprocess.PIPE,
>>>
On Wed, Nov 30, 2016 at 4:54 PM, duncan smith wrote:
>
> Thanks. So something like the following might do the job?
>
> def _execute(command):
> p = subprocess.Popen(command, shell=False,
> stdout=subprocess.PIPE,
> stderr=subprocess.STDOUT,
>
s only developers
writing extension modules that need to care - and only then if they
need maximum performance, and thus cannot convert every string they
access to UTF32 or UTF8.
--
Chris Kaynor
--
https://mail.python.org/mailman/listinfo/python-list
.
On Fri, Jan 20, 2017 at 3:15 PM, Thomas Nyberg wrote:
> On 01/20/2017 03:06 PM, Chris Kaynor wrote:
>>
>>
>> [...snip...]
>>
>> --
>> Chris Kaynor
>>
>
> I was able to delete my response which was a wholly contained subset of this
>
On Fri, Apr 1, 2016 at 1:52 PM, Ian Kelly wrote:
> On Fri, Apr 1, 2016 at 2:39 PM, Rob Gaddi
> wrote:
> > Fillmore wrote:
> >> Nope, wrong! contrary to what I thought I had understood about how
> >> parameters are passed in Python, the function is acting on a copy(!) and
> >> my original list is
On Tue, Apr 26, 2016 at 9:32 AM, Steven D'Aprano
wrote:
> Subclassing immutable built-ins is the most obvious and simple (and
> probably
> common) way to get an immutable class. Actually immutable, short of doing
> wicked things with ctypes.
>
By wicked things with ctypes, do you mean something
On Tue, Apr 26, 2016 at 10:04 AM, Chris Angelico wrote:
> On Wed, Apr 27, 2016 at 2:59 AM, Chris Kaynor
> wrote:
> > On Tue, Apr 26, 2016 at 9:32 AM, Steven D'Aprano
> > wrote:
> >
> >> Subclassing immutable built-ins is the most obvious and simple (and
&g
On Wed, May 18, 2016 at 9:19 AM, Ned Batchelder
wrote:
> I believe the issue here is that Python recursion results in the C stack
> growing. Each Python function call creates a number of C function calls,
> which grows the C stack. The crash you see is the C stack overflowing.
>
> Is there a wa
On Wed, May 18, 2016 at 10:15 AM, Steven D'Aprano
wrote:
> I don't really understand why the system can't track the current top of the
> stack and bottom of the heap, and if they're going to collide, halt the
> process. That would still be kinda awful, in a sudden "your application
> just died" k
On Thu, Jul 21, 2016 at 4:54 PM, Ben Bacarisse wrote:
> Steven D'Aprano writes:
>
> > Or you might be using a language like Javascript, which intentionally has
> > only floats for numbers. That's okay, you can still perform exact integer
> > arithmetic, so long as you stay within the bounds of
def __init__(self, name: str):
That "name: str" syntax is called function annotations, and was added in
Python 3, and you are trying to use the module in Python 2.7.
There may be another variation of the module compatible with Python 2, or
you'll need to upgrade your Python to a version of Python
On Tue, Nov 26, 2013 at 4:01 PM, Victor Hooi wrote:
> Hi,
>
> I'm trying to use Python's new style string formatting with a dict and
> string together.
>
> For example, I have the following dict and string variable:
>
> my_dict = { 'cat': 'ernie', 'dog': 'spot' }
> foo = 'lorem ipsum'
>
>
On Wed, Nov 27, 2013 at 12:09 PM, Ned Batchelder wrote:
> * Is there perhaps a better way to achieve what I'm trying to do?
>>
>> What I'm really after, is to check that python expressions embedded in
>> text files are:
>> - well behaved (no syntax errors etc)
>> - don't accidentally access anythi
On Mon, Dec 16, 2013 at 2:19 PM, Djoser wrote:
> Hi all,
>
> I am new to this forum and also to Python, but I'm trying hard to
> understand it better.
> I need to create a binary file, but the first 4 lines must be in
> signed-Integer16 and all the others in signed-Integer32. I have a program
>
On Tue, Jan 21, 2014 at 11:04 AM, Travis Griggs wrote:
> Being a fan of JIT, I have big hopes for PyPy, I can’t figure out why they
> aren’t pitching their “cutting edge” interpreter, for the “cutting edge”
> version of python. There should be a wall of superpowers/shame for
> interpreters.
A ve
On Mon, Jan 25, 2016 at 9:48 AM, Chris Angelico wrote:
> On Tue, Jan 26, 2016 at 4:32 AM, Random832 wrote:
> > On Mon, Jan 25, 2016, at 12:23, Chris Angelico wrote:
> >> if some translations don't use a token at all,
> >
> > I'm not sure what situation that would be reasonable in.
>
> I don't do
On Tue, Feb 9, 2016 at 5:58 PM, Anthony Papillion
wrote:
>
> On 02/09/2016 07:47 PM, Ben Finney wrote:
> > Anthony Papillion writes:
> >
> >> On 02/09/2016 07:26 PM, Anthony Papillion wrote:
> >>> I am using datetime.now() to create a unique version of a filename.
> >>> […]
> >>
> >> Found the so
On Tue, Feb 23, 2016 at 2:19 PM, Wildman via Python-list <
[email protected]> wrote:
> I am familiar with OO programming but I am new to Python
> and Tkinter. I am working on a gui program that creates
> a couple of temporary files. As part of the Exit button
> command they are deleted. If
On Mon, Mar 7, 2016 at 3:21 PM, Fillmore
wrote:
> On 3/7/2016 6:17 PM, Ian Kelly wrote:
>
>> On Mon, Mar 7, 2016 at 4:09 PM, Fillmore
>> wrote:
>>
>>>
>>> I must be missing something simple because I can't find a way to break
>>> out
>>> of a nested loop in Python.
>>>
>>> Is there a way to labe
On Thu, Mar 10, 2016 at 4:05 PM, BartC wrote:
> Here's a rather un-Pythonic and clunky version. But it gives the expected
> results. (I've dispensed with file input, but that can easily be added
> back.)
>
> def last(a):
> return a[-1]
>
> def init(a): # all except last elemen
On Wed, Nov 12, 2014 at 1:07 PM, Joel Goldstick
wrote:
> On Wed, Nov 12, 2014 at 4:02 PM, John Ladasky
> wrote:
> > I have taught Python to several students over the past few years. As I
> have worked with my students, I find myself bothered by the programming
> idiom that we use to determine w
On Wed, Nov 12, 2014 at 1:51 PM, Ian Kelly wrote:
> On Wed, Nov 12, 2014 at 2:33 PM, Chris Kaynor
> wrote:
> > A decorator is an interesting idea, and should be easy to implement (only
> > lightly tested):
> >
> > def main(func):
> > if func.__module__
On Wed, Nov 19, 2014 at 11:14 AM, Skip Montanaro
wrote:
> I discussion on the code-quality list got me thinking. Suppose I have
> an old-style class in a 2.x app:
>
> class Foo:
> def __init__(self):
> blah blah blah
>
> I still use 2.x exclusively, but anytime I run pylint over a bit of
>
On Mon, Dec 8, 2014 at 2:10 PM, bSneddon wrote:
> I ran into an issue setting variables from a GUI module that imports a
> back end module. My approach was wrong obviously but what is the best way
> to set values in a back end module.
>
> #module name beTest.py
>
> cfg = { 'def' : 'blue'}
>
> de
On Wed, Dec 10, 2014 at 7:15 PM, Steven D'Aprano
wrote:
> On Wed, 10 Dec 2014 18:18:44 -0800, Rustom Mody wrote:
>
>
> > And going the other way -- no defs only lambdas its this:
> >
> >
> f = lambda : (lambda x= {}: x)
> f()() is f()()
> > False
> d = f()
> d() is d()
> > Tru
On Thu, Jan 8, 2015 at 6:57 AM, Ian Kelly wrote:
> On Wed, Jan 7, 2015 at 11:21 PM, Marko Rauhamaa wrote:
> > Steven D'Aprano :
> >
> >> Marko Rauhamaa wrote:
> >>> I prefer the Scheme way:
> >>>#f is a falsey object
> >>>everything else is a truthy object
> >>
> >> The Scheme way has no
On Wed, Jan 14, 2015 at 2:16 PM, Chris Angelico wrote:
> And then you seek to run multiple workers. If my reading is correct,
> one of them (whichever one happens to get there first) will read the
> STOP marker and finish; the others will all be blocked, waiting for
> more work (which will never
On Thu, Jan 22, 2015 at 2:12 PM, Ian Kelly wrote:
>>> def adder(a,b): return a+b
>>>
>>> This is one of the pythonic idioms that help with polymorphic functions. Is
>>> there a proposal for providing hinting for these?
>>
>> You can use TypeVar for that.
>>
>> T = TypeVar('T')
>>
>> def adder(a:
On Wed, Jan 28, 2015 at 10:42 AM, Devin Jeanpierre
wrote:
> FWIW I put all my source code inside Dropbox so that even things I
> haven't yet committed/pushed to Bitbucket/Github are backed up. So far
> it's worked really well, despite using Dropbox on both Windows and
> Linux. (See also: Google Dr
On Wed, Jan 28, 2015 at 3:01 PM, Devin Jeanpierre
wrote:
> On Wed, Jan 28, 2015 at 2:02 PM, Chris Angelico wrote:
>> On Thu, Jan 29, 2015 at 8:52 AM, Devin Jeanpierre
>> wrote:
>>> Git doesn't help if you lose your files in between commits, or if you
>>> lose the entire directory between pushes.
On Thu, Jan 29, 2015 at 1:59 PM, Mark Lawrence wrote:
> On 29/01/2015 21:32, alb wrote:
>>
>> Hi MRAB,
>>
>> MRAB wrote:
>> []
>
> SyntaxError: invalid syntax
> debian@debian:example$ python3 export_latex.py doctree.csv
>File "export_latex.py", line 36
> yield from ch
On Thu, Jan 29, 2015 at 2:57 PM, BartC wrote:
> I've read most of the thread but haven't been able to figure out /why/ this
> is being proposed. What is the advantage, speed?
Check out the rationale part of the PEP:
https://www.python.org/dev/peps/pep-0484/#rationale-and-goals. Other
parts of the
On Wed, Feb 4, 2015 at 12:16 PM, Travis Griggs wrote:
>
>> On Feb 4, 2015, at 9:22 AM, Ian Kelly wrote:
>>
>> On Wed, Feb 4, 2015 at 9:50 AM, Travis Griggs wrote:
>>> I really like pymongo. And I really like Python. But one thing my fingers
>>> really get tired of typing is
>>>
>>> someDoc[‘_’i
On Mon, Feb 9, 2015 at 4:42 PM, Steven D'Aprano
wrote:
> so that's an excellent sign that doing so is best practice, but it should
> not be seen as *required*. After all, perhaps you have good reason for
> wanting your iterable class to only be iterated over once.
In fact, there is one in the std
On Tue, Feb 10, 2015 at 12:30 AM, Ian Kelly wrote:
>
> On Mon, Feb 9, 2015 at 5:59 PM, Chris Kaynor wrote:
> > On Mon, Feb 9, 2015 at 4:42 PM, Steven D'Aprano
> > wrote:
> >> so that's an excellent sign that doing so is best practice, but it should
>
On Fri, Feb 20, 2015 at 6:42 PM, Mario Figueiredo wrote:
> import sqlite3 as lite
>
> try:
> db = lite.connect('data.db')
> except lite.DatabaseError:
> raise OSError('database file corrupt or not found.')
> else:
> try:
>
On Tue, Feb 24, 2015 at 3:05 PM, wrote:
> >>> 'http://xthunder'.strip('http://')
> 'xthunder'
> >>> 'http://thunder'.strip('http://')
> 'under'
> >>>
>
> I could understand backslash but forward slash?
I believe the issue is that str.strip does not do quite what you are
thinking it does, howeve
On Tue, Feb 24, 2015 at 4:07 PM, Chris Angelico wrote:
> On Wed, Feb 25, 2015 at 10:50 AM, Skip Montanaro
> wrote:
> > Even if/when we get to the point where machines can hold an array of
> > 2**49 elements, I suspect people won't be using straight Python to
> > wrangle them.
>
> Looking just at
On Wed, Feb 25, 2015 at 8:44 AM, Sturla Molden wrote:
>
> On 25/02/15 17:04, Peter Otten wrote:
>
>> These guys found a bug that is subtler than what most of us have dealt with
>> in a widely used piece of code originally developed by one of the smarter
>> members of the python "community".
>>
>>
1 - 100 of 204 matches
Mail list logo