On 6 May 2013 17:05, Chris Angelico wrote:
> I've never used Twisted, so I can't say how good it is. All I know is
> that what I learned about socket programming in C on OS/2 is still
> valid on Windows and on Linux, and in every language I've ever used
> (bar JavaScript and ActionScript, which a
On 17 July 2012 13:01, Lipska the Kat wrote:
> Well I've set myself a task.
> I have a text file containing a list of stock items
> each line contains the number in stock followed by a tab followed by the
> name of the item. I need to implement something that reads in the text file
> and outputs
On 26 July 2012 13:26, Laszlo Nagy wrote:
[...]
> I do not want this program to generate very long identifiers. It would
> increase SQL parsing time, and don't look good. Let's just say that the
> limit should be 32 characters. But I also want to recognize the identifiers
> when I look at their mo
On 29 July 2012 06:36, rusi wrote:
> Just curious about your emacs+python usage.
> Do you use the emacs builtin python mode or the separate python-mode?
> Do you use pdb?
> Any other special setups?
One thing that I find very useful is to configure flymake to use
pyflakes. Very useful to get fee
On 6 August 2012 16:52, Tom P wrote:
> consider a nested loop algorithm -
>
> for i in range(100):
> for j in range(100):
> do_something(i,j)
>
> Now, suppose I don't want to use i = 0 and j = 0 as initial values, but some
> other values i = N and j = M, and I want to iterate through a
Hi all,
I'm writing a small GUI on OS X (v. 10.7.4) using Tkinter. I'm using
stock Python. It mostly works fine but there is a bug in Entry
widgets: if and Entry widget has focus and I press the UP arrow, a
"\uf700" gets inserted in the widget. If I press the DOWN arrow, a
"\uf701" gets inserte
On 31 August 2012 15:25, Kevin Walzer wrote:
> On 8/31/12 6:18 AM, Arnaud Delobelle wrote:
>>
>> I'm very inexperienced with Tkinter (I've never used it before). All
>> I'm looking for is a workaround, i.e. a way to somehow suppress that
>> output.
>
On 31 August 2012 16:41, Alister wrote:
> On Fri, 31 Aug 2012 11:21:14 -0400, Kevin Walzer wrote:
>
>> On 8/31/12 11:18 AM, Arnaud Delobelle wrote:
>>
>>
>>> I'm not trying to do anything. When a user presses the UP or DOWN
>>> arrow, then a stran
On Friday, 31 August 2012, Dennis Lee Bieber wrote:
> On Fri, 31 Aug 2012 15:41:01 GMT, Alister
>
> >
> declaimed the following in gmane.comp.python.general:
>
> > I agree that it is unexpected in a single line entry box but isn't the
> 1st
> > rule of user interface design to assume the user is
On 1 September 2012 11:30, Peter Otten <__pete...@web.de> wrote:
> Arnaud Delobelle wrote:
>> It would be good if I could intercept the key press event and cancel its
>> action on the Entry widget. It's easy to intercept the key event, but I
>> haven'
Hi all,
I'm looking for a way to run Lua scripts in Python, and also send and
receive data between the two. Something like lunatic-python [1] would
be ideal. However, so far I haven't been able to build it on the
machines it's supposed to run on (macs with OS X Lion) and it seems to
be dormant.
On 2 September 2012 10:39, Alec Taylor wrote:
> Or you can use a module made for this task:
>
> http://labix.org/lunatic-python
As I said in my original message, I couldn't get this to work.
> http://pypi.python.org/pypi/lupa
I'll check this out, thanks.
--
Arnaud
--
http://mail.python.org/m
On 2 September 2012 10:49, Arnaud Delobelle wrote:
> On 2 September 2012 10:39, Alec Taylor wrote:
>> http://pypi.python.org/pypi/lupa
>
> I'll check this out, thanks.
Mmh it seems to be lua 5.1 and more importantly it seems to require a
custom build of Python, which I don&
On 2 September 2012 19:42, Stefan Behnel wrote:
> Arnaud Delobelle, 02.09.2012 20:34:
>> On 2 September 2012 10:49, Arnaud Delobelle wrote:
>>> On 2 September 2012 10:39, Alec Taylor wrote:
>>>> http://pypi.python.org/pypi/lupa
>>>
>>> I'll che
On 30 September 2012 02:27, Kevin Anthony wrote:
> I have a list of filenames, and i need to find files with the same name,
> different extensions, and split that into tuples. does anyone have any
> suggestions on an easy way to do this that isn't O(n^2)?
>>> import os, itertools
>>> filenames =
On 31 October 2012 22:33, Steven D'Aprano
wrote:
[...]
> I don't killfile merely for posting from Gmail
And we are humbly grateful.
--
Arnaud
--
http://mail.python.org/mailman/listinfo/python-list
On 31 October 2012 23:09, Steven D'Aprano
wrote:
> The trick is to take each string and split it into a leading number and a
> trailing alphanumeric string. Either part may be "empty". Here's a pure
> Python solution:
>
> from sys import maxsize # use maxint in Python 2
> def split(s):
> for
Dear Pythoneers,
I've got a seemingly simple problem, but for which I cannot find a
simple solution.
I have a set of objects (say S) containing an object which is equal to
a given object (say x). So
x in S
is true. So there is an object y in S which is equal to x. My
problem is how to ret
On 1 February 2012 03:16, Paulo da Silva wrote:
> Em 01-02-2012 01:39, Paulo da Silva escreveu:
>> Hi!
>>
>> What is the best way to iterate thru a huge list having the 1st element
>> a different process? I.e.:
>>
>> process1(mylist[0])
>> for el in mylist[1:]:
>> process2(el)
>>
>> This way
On 1 February 2012 00:54, Emmanuel Mayssat wrote:
> I have the following program.
> I am trying to have index the attributes of an object using __getitem__.
> Reading them this way works great, but assigning them a value doesn't
> Is there a way to do such a thing?
> (Almost like a named tuple, bu
On 1 February 2012 08:11, Peter Otten <__pete...@web.de> wrote:
> Arnaud Delobelle wrote:
> The example should be
>
>> from itertools import islice:
>
> for el in islice(mylist, 1, None):
>> process2(el)
Oops!
--
Arnaud
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 1, 2012 9:01 PM, "Russell E. Owen" wrote:
>
> I have an odd and very intermittent problem in Python script.
> Occasionally it fails with this error:
>
> Traceback (most recent call last):
> File
> "/Applications/APO/TTUI.app/Contents/Resources/lib/python2.7/TUI/Base/Bas
> eFocusScript.py",
On 4 February 2012 10:14, Antti J Ylikoski wrote:
> On 4.2.2012 4:47, Chris Rebert wrote:
>> Out of curiosity, what would be non-Common-Lisp-style closures?
>>
>> Cheers,
>> Chris
>
>
> I understand that a "closure" is something which is typical of functional
> programming languages. -- Scheme-st
On 7 February 2012 20:23, Sammy Danso wrote:
>
> Hi Expert,
> Thanks for your responses and help. thought I should provide more information
> for clarity.
Please don't top-post.
> Please find the error message below for more information
>
> for (key, value) in wordFreq2:
> ValueError: need m
On 7 February 2012 22:57, Dennis Lee Bieber wrote:
> On Tue, 7 Feb 2012 21:37:20 +0000, Arnaud Delobelle
> wrote:
>
>
>>
>>Your list is flat so the unpacking fails. For it to work, you need
>>your list to be of the form:
>>
>> wordFreq2 = [('w
On 9 February 2012 14:00, Laurent Claessens wrote:
>
>> Here is my question: I would like to start an in-house library of small
>> modules to import, for things like error handling/logging. That's easy
>> enough, but is there a recommended way of naming such modules? I am
>> concerned about avoidi
On 10 February 2012 06:21, Ian Kelly wrote:
> (3219 + 99) // 100 * 100
>> 3300
> (3289 + 99) // 100 * 100
>> 3300
> (328678 + 99) // 100 * 100
>> 328700
> (328 + 99) // 100 * 100
>> 400
>>
>> Those are all rounded up to the nearest 100 correctly.
>
> One thing to be aware of though
On 10 February 2012 03:27, Terry Reedy wrote:
> On 2/9/2012 8:04 PM, Steven D'Aprano wrote:
>
>> Python happily violates "consenting adults" all over the place. We have
>> properties, which can easily create read-only and write-once attributes.
>
>
> So propose that propery() work at module level,
On 10 February 2012 00:05, Ethan Furman wrote:
> Ethan Furman wrote:
>>
>> Hrm -- and functions/classes/etc would have to refer to each other that
>> way as well inside the namespace... not sure I'm in love with that...
>
>
>
> Not sure I hate it, either. ;)
>
> Slightly more sophisticated code:
On 8 February 2012 01:48, Lei Cheng wrote:
> Hi all,
>
> In a py file, when to use import statements in the header, when to use
> import statements in the blocks where they are used?
> What are the best practices?
> Thanks!
Aside from other answers: in some rare cases, importing within a
On 10 February 2012 12:30, sajuptpm wrote:
> Hi,
>
> I want to log time taken to complete database requests inside a method/
> function using decorator . is it possible
> I think, i have to inject log code inside the method/fuctions or
> modify it.
> I wrote a decorator to log taken by a met
On 10 February 2012 21:06, John Gordon wrote:
> Recently I was been bitten by some stupid errors in my code, and I'm
> wondering if there's a simple way to catch them.
>
> One error was of the form:
>
> my_object.some_function()
>
> .. when I hadn't declared an object named "my_object".
>
> The o
On 13 February 2012 19:50, waylan wrote:
> When I try running any Python Script on the command line with Python
> 3.2 I get this weird behavior. The cursor dances around the command
> line window and nothing ever happens. Pressing Ctr+C does nothing.
> When I close the window (mouse click on X in
On 14 February 2012 15:31, Dennis Lee Bieber wrote:
> On Tue, 14 Feb 2012 16:01:05 +0100, Jabba Laci
> wrote:
>
>>Could someone please tell me what the following sorting algorithm is called?
>>
>>Let an array contain the elements a_1, a_2, ..., a_N. Then:
>>
>>for i = 1 to N-1:
>> for j = i+1
On 15 February 2012 09:47, Duncan Booth wrote:
> Rick Johnson wrote:
[...]
Perhaps it's a bit presumptuous of me but...
It's tempting to react to his inflammatory posts, but after all Rick
is a troll and experience shows that trolls are best left alone.
Also, please spare a thought for all of u
On 15 February 2012 17:23, Andrew Berg wrote:
> On 2/15/2012 10:04 AM, Mark Lawrence wrote:
>> I didn't realise that this was available until today. It doesn't appear
>> to be prominent in the official docs or have I missed something?
>> Certainly I'd have thought a couple of sentences here
>> ht
On 16 February 2012 05:03, Ian Kelly wrote:
> On Wed, Feb 15, 2012 at 6:11 PM, HoneyMonster
> wrote:
>> As to your first suggestion though, I am having some difficulty. Note
>> that the vulnerability rotates; i.e. CONDITIONS[4] is not the same as
>> CONDITIONS[0].
>> Is there a better way of doi
On 16 February 2012 21:10, Prasad, Ramit wrote:
>>> When you reply to a known bot, please include some indication of the
>>> fact, so we know your message can be ignored as well.
>
>>Sometimes I wonder about 8. Is there a real person there, as well as the
>>bot? A lot of his/its
> posts look
On 17 February 2012 07:53, Zheng Li wrote:
> def method1(a = None):
> print a
>
> i can call it by
> method1(*(), **{'a' : 1})
>
> I am just curious why it works and how it works?
> and what do *() and **{'a' : 1} mean?
>
> when I type *() in python shell, error below happens
>
> File "",
On 20 February 2012 16:03, Jason Friedman wrote:
> I am logging to HTTP:
>
> logger.addHandler(logging.handlers.HTTPHandler(host, url))
>
> Works great, except if my HTTP server happens to be unavailable:
>
> socket.error: [Errno 111] Connection refused
>
> Other than wrapping all my logger.log()
On 23 February 2012 21:19, Buck Golemon wrote:
> I feel like the design of sum() is inconsistent with other language
> features of python. Often python doesn't require a specific type, only
> that the type implement certain methods.
>
> Given a class that implements __add__ why should sum() not be
On 23 February 2012 21:23, Buck Golemon wrote:
> def sum(values,
> base=0):
> values =
> iter(values)
>
> try:
> result = values.next()
> except StopIteration:
> return base
>
> for value in values:
> result += value
> return result
This is defi
On 23 February 2012 21:53, Chris Angelico wrote:
> On Fri, Feb 24, 2012 at 8:41 AM, Arnaud Delobelle wrote:
>> _sentinel = object()
>>
>> def sum(iterable, start=_sentinel):
>> if start is _sentinel:
>>
>> del _sentinel
>
> Somewhat off-topic: Doe
On 23 February 2012 22:04, Chris Angelico wrote:
> On Fri, Feb 24, 2012 at 8:59 AM, Arnaud Delobelle wrote:
>> def sum(iterable, start=_sentinel, _sentinel=_sentinel):
>
> Is this a reason for Python to introduce a new syntax, such as:
>
> def foo(blah, optional=del):
&g
On 24 February 2012 12:25, Steven D'Aprano
wrote:
> Python 3.2 includes turtledemo, a demonstration program for the turtle
> module.
>
> When I run it, I can load the turtle scripts, and the GUI application
> says "Press the start button", but there is no start button.
>
> Can anyone else confirm
On 24 February 2012 14:54, Steven D'Aprano
wrote:
> for...else is a very useful construct, but the name is misleading. It
> took me a long time to stop thinking that the else clause executes when
> the for loop was empty.
This is why I think we should call this construct "for / break / else"
rat
On 26 February 2012 13:38, Wolfgang Meiners wrote:
> do_it = (len(str) <= maxlength) if maxlength is not None else True
That's a funny way to spell:
do_it = maxlength is None or len(str) <= maxlength
--
Arnaud
--
http://mail.python.org/mailman/listinfo/python-list
On 28 February 2012 21:39, Mihai Badoiu wrote:
> On Tue, Feb 28, 2012 at 4:35 PM, Chris Rebert wrote:
>>
>> On Tue, Feb 28, 2012 at 10:33 AM, Mihai Badoiu wrote:
>> > I'm trying to compute the total CPU load of an external process and it's
>> > children. (so I cannot use resource.getrusage) Fo
On 1 March 2012 13:07, Rolf Wester wrote:
> Hi,
>
> I would like to define methods using exec like this:
>
> class A:
> def __init__(self):
> cmd = "def sqr(self, x):\n return x**2\nself.sqr = sqr\n"
> exec cmd
> a = A()
> print a.sqr(a, 2)
>
> This works, but I have to call sq
On 2 March 2012 18:52, shikha panghal wrote:
> Hi
>
> Please decoplile the .pyc code ,as i have lost my .py code.
Aha, a customer! I've written a module for this: unpyc3
(http://code.google.com/p/unpyc3/)
Here it is in action:
Python 3.2.1 (v3.2.1:ac1f7e5c0510, Jul 9 2011, 01:03:53)
[GCC 4.2
On Mar 4, 2012 9:04 AM, "Sirotin Roman" wrote:
>
> Hi.
> How exactly jython decides is object callable or not? I defined
> __call__ method but interpreter says it's still not callable.
> BTW, my code works in cpython
It will help if you show us the code.
--
Arnaud
--
http://mail.python.org/mai
On 12 March 2012 19:39, Virgil Stokes wrote:
> I have a rather large ASCII file that is structured as follows
>
> header line
> 9 nonblank lines with alphanumeric data
> header line
> 9 nonblank lines with alphanumeric data
> ...
> ...
> ...
> header line
> 9 nonblank lines with alphanumeric data
On 14 March 2012 20:37, Croepha wrote:
> Which is preferred:
>
> for value in list:
> if not value is another_value:
> value.do_something()
> break
>
> --or--
>
> if list and not list[0] is another_value:
> list[0].do_something()
Hard to say, since they don't do the same thing :)
I suspe
On 14 March 2012 22:15, Prasad, Ramit wrote:
> Only use 'is' if you are looking for objects like True,
> False, None or something that MUST be exactly the same object.
I've rarely seen valid uses of 'is True' or 'is False'.
--
Arnaud
--
http://mail.python.org/mailman/listinfo/python-list
On 14 March 2012 23:34, Kiuhnm wrote:
> I've just started to read
> The Quick Python Book (2nd ed.)
> The author claims that Python code is more readable than Perl code and
> provides this example:
>
> --- Perl ---
> sub pairwise_sum {
> my($arg1, $arg2) = @_;
> my(@result) = ();
> @list
On 15 March 2012 00:27, Chris Angelico wrote:
> On Thu, Mar 15, 2012 at 10:54 AM, Arnaud Delobelle wrote:
>> I don't know this book and there may be a pedagogical reason for the
>> implementation you quote, but pairwise_sum is probably better
>> implemented i
On 15 March 2012 22:35, Ben Finney wrote:
> Kiuhnm writes:
>
>> Moreover, I think that
>> if (
>>
>> ):
>>
>>
>>
>> is not very readable anyway.
>
> I agree, and am glad PEP 8 has been upda
On 19 March 2012 23:20, Ian Kelly wrote:
> I hope you don't mind if I critique your code a bit!
>
> On Fri, Mar 16, 2012 at 7:21 PM, Kiuhnm
> wrote:
>> Here we go.
>>
>> --->
>> def genCur(f, unique = True, minArgs = -1):
>
> It is customary in Python for unsupplied arguments with no default to
>
On Mar 22, 2012 7:49 PM, "Rodrick Brown" wrote:
>
> #!/usr/bin/python
>
> def main():
>
>str1='this is a test'
>str2='t'
>
>print "".join([ c for c in str1 if c not in str2 ])
>print(str1.strip(str2))
>
> if __name__ == '__main__':
>main()
>
> ./remove_str.py
> his is a es
> hi
On 22 March 2012 20:04, Rodrick Brown wrote:
>
> On Mar 22, 2012, at 3:53 PM, Arnaud Delobelle wrote:
> Try help(ste.strip)
>
> It clearly states "if chars is given and not None, remove characters in
> chars instead.
>
> Does it mean remove only the first occurrence
On 5 April 2012 21:06, Emile van Sebille wrote:
> Kind of begs for a contains method that returns the appropriate boolean:
>
> if text.contains('bob')
It's already there:
text.__contains__('bob')
It's usually spelt otherwise though:
'bob' in text
--
Arnaud
--
http://mail.python.org/
On 13 April 2012 17:35, Kiuhnm wrote:
> On 4/13/2012 17:58, Alexander Blinne wrote:
>>
>> zip(*[x[1] for x in sorted(d.items(), key=lambda y: y[0])])
>
> Or
> zip(*[d[k] for k in sorted(d.keys())])
.keys() is superfluous here:
zip(*(d[k] for k in sorted(d)))
--
Arnaud
--
http://mail.pyth
On 16 April 2012 13:01, Alan Ristow wrote:
> Hi all,
>
> I have defined a class that includes a number of helper methods that
> are useful to me, but pretty redundant. Something like so, where I
> maintain a list of tuples:
>
> class A(object):
> def __init__(self):
> self.listing = []
>
On 16 April 2012 13:29, Arnaud Delobelle wrote:
> You can do this (untested), but no doubt it won't be to everybody's taste:
>
> class A(object):
> def __init__(self):
> self.listing = []
>
> # This method does the work.
>
On 17 April 2012 09:54, Bryan wrote:
> Django has emphasized backwards compatibility with the
> down-side that, last I heard, there was no plan to move to Python 3.
Not quite:
https://www.djangoproject.com/weblog/2012/mar/13/py3k/
--
Arnaud
--
http://mail.python.org/mailman/listinfo/python-li
On 26 April 2012 12:42, Adam Skutt wrote:
> On Apr 26, 5:10 am, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote:
>> On Wed, 25 Apr 2012 20:50:21 -0700, Adam Skutt wrote:
>> > On Apr 25, 8:01 pm, Steven D'Aprano > > +comp.lang.pyt...@pearwood.info> wrote:
>> >> On Wed, 25 Apr 2012 13:49:24
(sent from my phone)
On Apr 28, 2012 7:36 PM, "Chris Rebert" wrote:
> Correct. Pedantically, you can define __hash__() on mutable objects;
> it's just not very useful or sensible, so people generally don't.
I find it's fine to define __hash__ on mutable objects as long as __eq__
only relies on im
(sent from my phone)
On May 1, 2012 6:42 PM, "Jerry Hill" wrote:
>
> On Tue, May 1, 2012 at 1:07 PM, Kiuhnm
> wrote:
> > If you had read the module's docstring you would know that the public
> > version uses
>
> Are you aware that you've never posted a link to your module, nor it's
> docstrings?
On 7 May 2012 12:31, Nikhil Verma wrote:
> HI All
>
> I was clearing my concepts on dictionary and stuck in this problem.
> I have a dictionary which i have formed by using zip function on two list so
> that one list (which i have hardcoded) becomes the keys and the other list
> becomes its values
On 13 May 2012 13:29, Alec Taylor wrote:
> There is an ordered dict type since Python 3.1[1] and Python 2.7.3[2].
I don't think that'll help the OP. Python's OrderedDict keeps track
of the order in which the keys were inserted into the dictionary (a
bit like a list), it doesn't keep the keys sor
On 15 May 2012 20:55, Ned Deily wrote:
> In article
> ,
> msmucr wrote:
>> i would like to ask you for some information regarding Carbon Event
>> Manager ( Carbon.CarbonEvt ) library in Python.
>> I need to recieve and work with few Carbon events in my program. I've
>> followed some examples on
On 19 May 2012 06:23, John O'Hagan wrote:
> To revisit a question which I'm sure none of you remember from when I posted
> it
> a year or so ago - there were no takers at the time - I'd like to try again
> with
> a more concise statement of the problem:
>
> How to generate only the distinct perm
On 24 May 2012 21:22, Scott Siegler wrote:
> Hello,
>
> I am an experienced programmer but a beginner to python. As such, I can
> figure out a way to code most algorithms using more "C" style syntax.
>
> I am doing something now that I am sure is a more python way but i can't
> quite get it rig
On 30 May 2012 12:54, Thomas Rachel
wrote:
> There is a 3rd one: use r'[ ' + '\u3000' + ']'. Not very nice to read, but
> should do the trick...
You could even take advantage of string literal concatenation:)
r'[' '\u3000' r']'
--
Arnaud
--
http://mail.python.org/mailman/listinfo/python
On 10 June 2012 07:16, rusi wrote:
> This is worth a read in this context: http://osteele.com/archives/2004/11/ides
Interesting! I definitely fall nicely at one extreme of this
dichotomy. Every time I've tried to use an IDE, it's made me feel
inadequate and I've quickly retreated to my comfort
On 18 June 2012 12:31, Valentin Mercier wrote:
> Hi,
>
> I'm trying to search some mails with SUBJECT criteria, but the problem is
> the encoding, I'm trying to search french terms (impalib and python V2.7)
>
> I've tried few things, but I think the encoding is the problem, in my mail
> header I h
Hi all,
In Python 3, a function f's code object can be accessed via f.__code__.
I'm interested in getting a module's code object, i.e. the code that
is executed when the module is run. I don't think it's accessible via
the module object itself (although I would be glad if somebody proved
me wron
On Aug 25, 3:30 pm, t...@thsu.org wrote:
> What is the most common way to handle default function arguments that
> are set at run time, rather than at compile time? The snippet below is
> the current technique that I've been using, but it seems inelegant.
>
> defaults = { 'debug' : false }
> def do
On 25 August 2011 16:07, Peter Otten <__pete...@web.de> wrote:
> Arnaud Delobelle wrote:
>
>> In Python 3, a function f's code object can be accessed via f.__code__.
>>
>> I'm interested in getting a module's code object,
[...]
>
> Taken from
Hi all,
Here is an extract from the dis module doc [1]
"""
RAISE_VARARGS(argc)
Raises an exception. argc indicates the number of parameters to the
raise statement, ranging from 0 to 3. The handler will find the
traceback as TOS2, the parameter as TOS1, and the exception as TOS.
"""
OTOH, looking
On 27 August 2011 07:49, Peter Otten <__pete...@web.de> wrote:
> Arnaud Delobelle wrote:
>
>> Here is an extract from the dis module doc [1]
>>
>> """
>> RAISE_VARARGS(argc)
>> Raises an exception. argc indicates the number of parameters to
Hi all,
I'm wondering what advice you have about formatting if statements with
long conditions (I always format my code to <80 colums)
Here's an example taken from something I'm writing at the moment and
how I've formatted it:
if (isinstance(left, PyCompare) and isinstance(right, PyComp
On 27 August 2011 08:24, Steven D'Aprano
wrote:
> Arnaud Delobelle wrote:
>
>> Hi all,
>>
>> I'm wondering what advice you have about formatting if statements with
>> long conditions (I always format my code to <80 colums)
>>
>> Here's a
On 29 August 2011 23:14, Jack Trades wrote:
> On Mon, Aug 29, 2011 at 12:30 PM, Rob Williscroft wrote:
>>
>> Jack Trades wrote in
>> > ... I wanted to allow the user to manually return the
>> > function from the string, like this:
>> >
>> > a = exec("""
>> > def double(x):
>> > return x * 2
>>
On 29 August 2011 04:08, Russ P. wrote:
> On Aug 28, 7:51 pm, Chris Angelico wrote:
>> On Mon, Aug 29, 2011 at 12:41 PM, Russ P. wrote:
>> > On Aug 28, 6:52 pm, MRAB wrote:
>> >> You could look at the return value of os.system, which may tell you the
>> >> exit status of the process.
>>
>> > Th
On 30 August 2011 13:31, Jack Trades wrote:
>
>
> On Tue, Aug 30, 2011 at 2:37 AM, Rob Williscroft wrote:
>
>>
>> > That's brilliant and works flawlessly. Thank you very much!
>>
>> If an impementation (as you say up thread) can populate globals
>> or locals with whatever they want, then how do
On 30 August 2011 22:48, Rob Williscroft wrote:
> Arnaud Delobelle wrote in
> news:CAJ6cK1YVi3NQgdZOUdhAESf133pUkdazM1PkSP=p6xfayvo...@mail.gmail.com in
> gmane.comp.python.general:
>
>> On 30 August 2011 13:31, Jack Trades wrote:
>>>
>>>
>>> On
On 31 August 2011 17:45, Travis Parks wrote:
> I was a little disappointed the other day when I realized that
> closures were read-only. I like to use closures quite a bit.
>
> Can someone explain why this limitation exists? Secondly, since I can
> cheat by wrapping the thing being closure-ified,
On 8 July 2014 15:59, wrote:
>
> Looking for your opinions on how you name your functions and methods.
> Example: I have a function that hashes a file. I could name this function
> hash_file() or file_hash(). The 1st naming convention sounds more natural,
> the 2nd naming convention allows one
Hi all,
Unpyc3 can recreate Python3 source code from code objects, function
source code from function objects, and module source code from .pyc
files. The current version is able to decompile itself successfully
:). It has been tested with Python3.2 only.
It currently reconstructs most of Python
On 14 September 2011 06:53, Vincent Vande Vyvre
wrote:
>
> Hi, trying your code, I have had numbers of errors:
Hi Vincent, thanks for trying it.
> File "unpyc3.py", line 55, in
> SETUP_WITH,
> NameError: name 'SETUP_WITH' is not defined
>
> commented it
>
> File "unpyc3.py", line 58, in
On 14 September 2011 09:44, Vincent Vande Vyvre
wrote:
> File "unpyc3.py", line 211, in __init__
> for v in code_obj.co_cellvars + code_obj.co_freevars]
> AttributeError: 'NoneType' object has no attribute 'co_cellvars'
Could you show me what you do to get this error? Thank you,
Arnaud
P
On 14 September 2011 11:03, Vincent Vande Vyvre
wrote:
> Le 14/09/11 11:31, Arnaud Delobelle a écrit :
[...]
> Could you show me what you do to get this error? Thank you,
> [vincent@myhost unpyc3]$ python
> Python 3.2.1 (default, Jul 11 2011, 12:37:47)
> [GCC 4.6.1] on linu
Hi all,
You can do:
def foo():
"foodoc"
pass
function = type(lambda:0)
foo2 = function(foo.__code__, globals())
assert foo2.__doc__ == "foodoc"
I am wondering how the function constructor knows that foo.__code__
has a docstring. I can see that
foo.__code__.co_consts == ('foodoc',)
On 15 September 2011 16:17, Ian Kelly wrote:
> On Thu, Sep 15, 2011 at 5:10 AM, Arnaud Delobelle wrote:
>> Hi all,
>>
>> You can do:
>>
>> def foo():
>> "foodoc"
>> pass
>>
>> function = type(lambda:0)
>> foo2 = fun
On 15 September 2011 15:41, Matthew Pounsett wrote:
> On Sep 15, 1:35 am, Chris Rebert wrote:
>> Override __new__() instead:
>> http://docs.python.org/reference/datamodel.html#object.__new__
>
> Aha.. thanks! The reference book I'm working from neglects to mention
> __new__, so I'd assumed __ini
On 16 September 2011 21:06, Ian Kelly wrote:
> On Fri, Sep 16, 2011 at 1:21 PM, zombie
> wrote:
>> Hi guys,
>> i am writing a program to sum up the digits of a number 2**1000?
>> Is there a way/formula to do it without expanding it?
>
> Possibly, but why worry about it? It's only around
On 16 September 2011 21:20, Ian Kelly wrote:
> On Fri, Sep 16, 2011 at 2:17 PM, Arnaud Delobelle wrote:
>> Ah go on, let's make a codegolf contest out of it.
>> My entry:
>>
>>>>> sum(map(int,str(2**1000)))
>> 1366
>
> That is exactly what m
On 16 September 2011 20:21, zombie wrote:
> Hi guys,
> i am writing a program to sum up the digits of a number 2**1000?
> Is there a way/formula to do it without expanding it?
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
In base 2, the answer is 1 :)
Hopefully-helpfully
On Sep 18, 2011 1:20 PM, "Mark Dickinson" wrote:
>
> On Sep 16, 9:17 pm, Arnaud Delobelle wrote:
> > Ah go on, let's make a codegolf contest out of it.
> > My entry:
> >
> > >>> sum(map(int,str(2**1000)))
>
> You could save another
1 - 100 of 1128 matches
Mail list logo