Re: Overwhelmed by the Simplicity of Python. Any Recommendation?

2018-11-06 Thread Lie Ryan
> I like to step through my code line by line, > it's impossible to do it with > object-oriented programming language. I suggest pudb, it's a curses based debugger, which is nicer than pdb, but doesn't require tedious IDE setup. > Also, there's no good REPL IDE. Not quite sure what you meant

FW: Printing to a file and a terminal at the same time

2017-10-12 Thread Lie Ryan
It wouldn't be too difficult to write a file object wrapper that emulates tee, for instance (untested): class tee(object): def __init__(self, file_objs, autoflush=True): self._files = file_objs self._autoflush = autoflush def write(self, buf): for f in

Re: I love assert

2014-11-13 Thread Lie Ryan
On 13/11/14 10:05, Ian Kelly wrote: On Wed, Nov 12, 2014 at 3:47 PM, Marko Rauhamaa ma...@pacujo.net wrote: Ian Kelly ian.g.ke...@gmail.com: Apart from idiomatic style, there is no difference between # never reached assert False raise RuntimeError('Unreachable code reached')

Re: Communicating with a PHP script (and pretending I'm a browser)

2014-11-13 Thread Lie Ryan
On 13/11/14 03:57, Larry Martell wrote: We were all making this much harder than it is. I ended up doing this: wp = urllib.request.urlopen('http://php_page/?' + request.POST.urlencode()) pw = wp.read() I was about that suggest that actually, just be careful to escape things properly.

Re: [Python-Dev] Dinamically set __call__ method

2014-11-13 Thread Lie Ryan
On 05/11/14 06:15, Roberto Martínez wrote: The thing with this is tricky. I need the change in the instance, not in the class, because I have multiple instances and all of them must have different implementations of __call__. Why not just use functions with closure if that's what you need?

Re: PEP8 and 4 spaces

2014-07-04 Thread Lie Ryan
On 04/07/14 07:55, Gregory Ewing wrote: Steven D'Aprano wrote: That's exactly the problem with tabs - whatever you think your code looks like with tabs, other people will see quite different picture. Why do you consider this a problem? It's a problem if you try to use tabs for lining

Re: Single underscore in interactive mode

2014-06-25 Thread Lie Ryan
On 25/06/14 16:20, candide wrote: As explained by the docs, an assignment statement_evaluates_ the expression on the right hand side. So we can deduce that at the very beginning of the 2nd prompt, the result of the last evaluation is 43. Nevertheless, calling _ raises a NameError exception!

Re: Python ORM library for distributed mostly-read-only objects?

2014-06-23 Thread Lie Ryan
On 22/06/14 10:46, smur...@gmail.com wrote: I've been doing this with a classic session-based SQLAlchemy ORM, approach, but that ends up way too slow and memory intense, as each thread gets its own copy of every object it needs. I don't want that. If you don't want each thread to have their

Re: Python ORM library for distributed mostly-read-only objects?

2014-06-23 Thread Lie Ryan
On 23/06/14 19:05, smur...@gmail.com wrote: On Monday, June 23, 2014 5:54:38 PM UTC+2, Lie Ryan wrote: If you don't want each thread to have their own copy of the object, Don't use thread-scoped session. Use explicit scope instead. How would that work when multiple threads traverse

Re: why not?

2013-01-21 Thread Lie Ryan
On 22/01/13 04:02, kwakukwat...@gmail.com wrote: f = open(r'c:\text\somefile.txt') for i in range(3): print str(i) + ': ' + f.readline(), please with the print str(i) + ‘: ‘ + f.readline(), why not print str(i) + f.readline(), Try running both code. What do you see? What's the

Re: Any algorithm to preserve whitespaces?

2013-01-19 Thread Lie Ryan
On 19/01/13 21:13, Santosh Kumar wrote: I have a working script which takes argv[1] as an input, deassembles each line, and then each word. Then after it capitalizes all its word (upcases the first letter) and then prints it out on the stdout. That script does the capitalization work fine, but,

Re: Vote tallying...

2013-01-19 Thread Lie Ryan
On 19/01/13 00:43, Andrew Robinson wrote: On 01/18/2013 08:47 AM, Stefan Behnel wrote: Andrew Robinson, 18.01.2013 00:59: I have a problem which may fit in a mysql database Everything fits in a MySQL database - not a reason to use it, though. Py2.5 and later ship with sqlite3 and if you go

Re: Vote tallying...

2013-01-19 Thread Lie Ryan
On 20/01/13 08:22, Dennis Lee Bieber wrote: On Sat, 19 Jan 2013 22:58:17 +1100, Lie Ryan lie.1...@gmail.com Which is the same restriction as when using XML/JSON. What it means by locking the entire database is that an sqlite database can only be read/written by a single program at any moment

Re: Vote tallying...

2013-01-18 Thread Lie Ryan
On 18/01/13 10:59, Andrew Robinson wrote: Hi, I have a problem which may fit in a mysql database, but which I only have python as an alternate tool to solve... so I'd like to hear some opinions... Since you have a large dataset, you might want to use sqlite3

Re: Safely add a key to a dict only if it does not already exist?

2013-01-18 Thread Lie Ryan
On 19/01/13 15:15, Chris Rebert wrote: On Friday, January 18, 2013, 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

Re: python sys.stdout and C++ iostreams::cout

2013-01-17 Thread Lie Ryan
On 18/01/13 02:02, Utpal Sarkar wrote: Hi, I was assuming that sys.stdout would be referencing the same physical stream as iostreams::cout running in the same process, but this doesn't seem to be the case. The following code, which makes a call to a C++ function with a python wrapper called

Re: To make a method or attribute private

2013-01-17 Thread Lie Ryan
On 17/01/13 11:34, iMath wrote: To make a method or attribute private (inaccessible from the outside), simply start its name with two underscores 《Beginning Python From Novice to Professional》 but there is another saying goes: Beginning a variable name with a single underscore indicates

Re: Number of languages known [was Re: Python is readable] - somewhat OT

2012-04-08 Thread Lie Ryan
On 03/30/2012 06:25 AM, Steve Howell wrote: On Mar 29, 11:53 am, Devin Jeanpierrejeanpierr...@gmail.com wrote: Well, what sort of language differences make for English vs Mandarin? Relational algebraic-style programming is useful, but definitely a large language barrier to people that don't

Re: Python is readable

2012-03-31 Thread Lie Ryan
On 03/18/2012 12:36 PM, Steven D'Aprano wrote: On Sat, 17 Mar 2012 20:59:34 +0100, Kiuhnm wrote: In the second example, most English speakers would intuit that print(i) prints i, whatever i is. There are two points where the code may be misunderstood, a beginner may think that print i prints

Re: Python is readable

2012-03-31 Thread Lie Ryan
On 03/21/2012 03:55 AM, Nathan Rice wrote: In mathematics, when you perform global optimization you must be willing to make moves in the solution space that may result in a temporary reduction of your optimality condition. If you just perform naive gradient decent, only looking to the change

Re: Python is readable

2012-03-31 Thread Lie Ryan
On 03/21/2012 01:44 PM, Steve Howell wrote: Also, don't they call those thingies object for a reason? ;) A subject is (almost?) always a noun, and so a subject is also an object. -- http://mail.python.org/mailman/listinfo/python-list

Re: Tools for refactoring/obfuscation

2012-03-30 Thread Lie Ryan
On 03/29/2012 03:04 AM, Javier wrote: Yes, in general I follow clear guidelines for writing code. I just use modules with functions in the same directory and clear use of name spaces. I almost never use classes. I wonder if you use some tool for refactoring. I am mainly intersted in scripting

Re: [OT]: Smartphones and Python?

2012-02-18 Thread Lie Ryan
On 02/18/2012 12:51 PM, Michael Torrie wrote: On 02/16/2012 10:25 PM, 8 Dihedral wrote: Android is a customized linux OS used in mobile phones. I don't think any linux systm has to be locked by JAVA or any JVM to run applications. Getting waaa off topic here, but... I guess you

Re: Is a with on open always necessary?

2012-01-25 Thread Lie Ryan
On 01/26/2012 04:17 AM, K Richard Pixley wrote: On 1/21/12 03:38 , Lie Ryan wrote: It is only strictly necessary for programs that opens thousands of files in a short while, since the operating system may limit of the number of active file handlers you can have. The number you're looking

Re: Is a with on open always necessary?

2012-01-21 Thread Lie Ryan
On 01/21/2012 02:44 AM, Andrea Crotti wrote: I normally didn't bother too much when reading from files, and for example I always did a content = open(filename).readlines() But now I have the doubt that it's not a good idea, does the file handler stays open until the interpreter quits? It is

Re: PyWarts: time, datetime, and calendar modules

2012-01-15 Thread Lie Ryan
On 01/15/2012 06:23 AM, Rick Johnson wrote: So how do we solve this dilemma you ask??? Well, we need to mark method OR variable names (OR both!) with syntactic markers so there will be NO confusion. Observe: def $method(self):pass self.@instanceveriable self.@@classvariable There is

Re: replacing __dict__ with an OrderedDict

2012-01-10 Thread Lie Ryan
On 01/10/2012 12:05 PM, Roy Smith wrote: Somewhat more seriously, let's say you wanted to do test queries against a database with 100 million records in it. You could rebuild the database from scratch for each test, but doing so might take hours per test. Sometimes, real life is just*so*

Re: replacing __dict__ with an OrderedDict

2012-01-10 Thread Lie Ryan
On 01/10/2012 12:16 AM, Ulrich Eckhardt wrote: Am 09.01.2012 13:10, schrieb Lie Ryan: I was just suggesting that what the OP thinks he wants is quite likely not what he actually wants. Rest assured that the OP has a rather good idea of what he wants and why, the latter being something you

Re: replacing __dict__ with an OrderedDict

2012-01-10 Thread Lie Ryan
On 01/10/2012 03:59 AM, Ulrich Eckhardt wrote: There is another dependency and that I'd call a logical dependency. This occurs when e.g. test X tests for an API presence and test Y tests the API behaviour. In other words, Y has no chance to succeed if X already failed. Unfortunately, there is

Re: python philosophical question - strong vs duck typing

2012-01-10 Thread Lie Ryan
On 01/09/2012 04:35 PM, John Nagle wrote: A type-inferring compiler has to analyze the whole program at once, because the type of a function's arguments is determined by its callers. This is slow. The alternative is to guess what the type of something is likely to be, compile code at run time,

Re: replacing __dict__ with an OrderedDict

2012-01-10 Thread Lie Ryan
On 01/11/2012 01:05 AM, Roy Smith wrote: In articlemailman.4588.1326198152.27778.python-l...@python.org, Lie Ryanlie.1...@gmail.com wrote: On 01/10/2012 12:05 PM, Roy Smith wrote: Somewhat more seriously, let's say you wanted to do test queries against a database with 100 million records

Re: replacing __dict__ with an OrderedDict

2012-01-09 Thread Lie Ryan
On 01/09/2012 09:03 AM, Eelco wrote: i havnt read every post in great detail, but it doesnt seem like your actual question has been answered, so ill give it a try. AFAIK, changing __dict__ to be an ordereddict is fundamentally impossible in python 2. __dict__ is a builtin language construct

Re: MOST COMMON QUESTIONS ASKED BY NON-MUSLIMS ?????????

2012-01-07 Thread Lie Ryan
On 01/04/2012 05:24 AM, gene heskett wrote: On Tuesday, January 03, 2012 01:13:08 PM John Ladasky did opine: On Jan 3, 7:40 am, BVbv5bv5...@yahoo.com wrote: MOST COMMON QUESTIONS ASKED BY NON-MUSLIMS Q0. Why do thousand-line religious posts appear in comp.lang.python? Already discussed,

Re: replacing __dict__ with an OrderedDict

2012-01-06 Thread Lie Ryan
On 01/06/2012 08:48 PM, Ulrich Eckhardt wrote: Hi! The topic explains pretty much what I'm trying to do under Python 2.7[1]. The reason for this is that I want dir(SomeType) to show the attributes in the order of their declaration. This in turn should hopefully make unittest execute my tests in

Re: replacing __dict__ with an OrderedDict

2012-01-06 Thread Lie Ryan
On 01/07/2012 12:36 AM, Ulrich Eckhardt wrote: Am 06.01.2012 12:43, schrieb Lie Ryan: On 01/06/2012 08:48 PM, Ulrich Eckhardt wrote: Hi! The topic explains pretty much what I'm trying to do under Python 2.7[1]. The reason for this is that I want dir(SomeType) to show the attributes

Re: replacing __dict__ with an OrderedDict

2012-01-06 Thread Lie Ryan
On 01/07/2012 04:20 AM, Ian Kelly wrote: On Fri, Jan 6, 2012 at 10:01 AM, Lie Ryanlie.1...@gmail.com wrote: That unittest executes its tests in alphabetical order is implementation detail for a very good reason, and good unittest practice dictates that execution order should never be defined

Re: how to get id(function) for each function in stack?

2012-01-06 Thread Lie Ryan
On 01/07/2012 06:50 AM, Ian Kelly wrote: On Fri, Jan 6, 2012 at 12:29 PM, dmitreydmitre...@gmail.com wrote: Python build-in function sum() has no attribute func_code, what should I do in the case? Built-in functions and C extension functions have no code objects, and for that reason they

Re: replacing __dict__ with an OrderedDict

2012-01-06 Thread Lie Ryan
On 01/07/2012 11:49 AM, Steven D'Aprano wrote: You may not be able to run tests*simultaneously*, due to clashes involving external resources, but you should be able to run them in random order. tests that involves external resources should be mocked, although there are always a few external

Re: a little help

2012-01-05 Thread Lie Ryan
On 01/05/2012 11:29 AM, Andres Soto wrote: my mistake is because I have no problem to do that using Prolog which use an interpreter as Python. I thought that the variables in the main global memory space (associated with the command line environment) were kept, although the code that use it

Re: help me get excited about python 3

2012-01-05 Thread Lie Ryan
On 01/05/2012 03:41 PM, Evan Driscoll wrote: On 1/4/2012 9:56 AM, Sean Wolfe wrote: I am still living in the 2.x world because all the things I want to do right now in python are in 2 (django, pygame). But I want to be excited about the future of the language. I understand the concept of

Re: a little help

2012-01-05 Thread Lie Ryan
On 01/06/2012 03:04 AM, Andres Soto wrote: Please, see my comments between your lines. Thank you very much for your explanation! * * *From:* Lie Ryan lie.1...@gmail.com *To:* python-list@python.org *Sent:* Thursday, January 5, 2012 2:30 AM *Subject:* Re: a little

Re: Spamming PyPI with stupid packages

2012-01-02 Thread Lie Ryan
On 01/02/2012 11:20 PM, Peter Otten wrote: Felinx Lee wrote: I have removed those packages (girlfriend and others) from PyPI forever, I apologize for that. The thought police has won :( I think the community has a right to defend themselves against trolls. If it's just bad naming, we can

Re: Spamming PyPI with stupid packages

2012-01-01 Thread Lie Ryan
On 01/02/2012 09:33 AM, Robert Kern wrote: On 1/1/12 10:18 PM, Matt Chaput wrote: Someone seems to be spamming PyPI by uploading multiple stupid packages. Not sure if it's some form of advertising spam or just idiocy. Don't know if we should care though... maybe policing uploads is worse than

Re: How to get function string name from i-th stack position?

2011-12-31 Thread Lie Ryan
On 12/31/2011 08:48 AM, Ian Kelly wrote: But they are two distinct function objects, and there is no way programmatically to determine that they are the same function except by comparing the bytecode (which won't work generally because of the halting problem). Actually, it is often possible

Re: .format vs. %

2011-12-31 Thread Lie Ryan
On 01/01/2012 05:44 AM, davidfx wrote: Thanks for your response. I know the following code is not going to be correct but I want to show you what I was thinking. formatter = %r %r %r %r print formatter % (1, 2, 3, 4) What is the .format version of this concept? I don't think the

Re: Py-dea: Streamline string literals now!

2011-12-29 Thread Lie Ryan
On 12/29/2011 12:44 PM, Dan Sommers wrote: On Wed, 28 Dec 2011 22:54:16 +, Steven D'Aprano wrote: On Wed, 28 Dec 2011 11:36:17 -0800, Rick Johnson wrote: The point is people, we should be using string delimiters that are ANYTHING besides and '. Stop being a sheep and use your brain!

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-29 Thread Lie Ryan
On 12/30/2011 12:23 AM, Steven D'Aprano wrote: On Thu, 29 Dec 2011 03:55:14 -0800, Eelco wrote: I would argue that the use of single special characters to signal a relatively complex and uncommon construct is exactly what I am trying to avoid with this proposal. This would be the proposal to

Re: Possible bug in string handling (with kludgy work-around)

2011-12-28 Thread Lie Ryan
On 12/28/2011 11:57 AM, Rick Johnson wrote: On Dec 27, 3:38 pm, Terry Reedytjre...@udel.edu wrote: On 12/27/2011 1:04 PM, Rick Johnson wrote: But this brings up a very important topic. Why do we even need triple quote string literals to span multiple lines? Good question, and one i have

Re: reverse() is not working

2011-12-28 Thread Lie Ryan
On 12/29/2011 05:02 AM, Nirmal Kumar wrote: I am trying to pass the id to thanks view through reverse. But it's not working. I'm getting this error Reverse for 'reg.views.thanks' with arguments '(20,)' and keyword arguments '{}' not found. I posted the question with the code in

Re: Py-dea: Streamline string literals now!

2011-12-28 Thread Lie Ryan
On 12/29/2011 06:36 AM, Rick Johnson wrote: mlstr = ||| this is a multi line sting that is delimited by triple pipes. Or we could just 'single pipes' if we like, however, i think the triple pipe' is easier to see. Since the pipe char is so rare in Python source, it becomes the obvious choice.

Re: Py-dea: Streamline string literals now!

2011-12-28 Thread Lie Ryan
On 12/28/2011 04:34 PM, Rick Johnson wrote: On Dec 27, 9:49 pm, Rick Johnsonrantingrickjohn...@gmail.com wrote: The fact is...even with the multi-line issue solved, we still have two forms of literal delimiters that encompass two characters resulting in *four* possible legal combinations of

Re: Pythonification of the asterisk-based collection packing/unpacking syntax

2011-12-28 Thread Lie Ryan
On 12/28/2011 11:08 PM, Eelco wrote: I personally feel any performance benefits are but a plus; they are not the motivating factor for this idea. I simply like the added verbosity and explicitness, thats the bottom line. Any performance benefits are a plus, I agree, as long as it doesn't make

Re: Which libraries for Python 2.5.2

2011-12-27 Thread Lie Ryan
On 12/28/2011 03:03 AM, W. eWatson wrote: Here's the traceback. The traceback seems to imply that matplotlib is not being installed properly. Have you tried uninstalling then reinstalling matplotlib? -- http://mail.python.org/mailman/listinfo/python-list

Re: Plot seems weird

2011-12-27 Thread Lie Ryan
On 12/27/2011 06:14 AM, Yigit Turgut wrote: On Dec 26, 8:58 pm, Lie Ryanlie.1...@gmail.com wrote: On 12/27/2011 04:08 AM, Yigit Turgut wrote: not your fault, I made a mistake when copy-pasteing the code, here's the fixed code: from itertools import izip_longest def to_square(data):

Re: python logging module:a quick question

2011-12-27 Thread Lie Ryan
On 12/27/2011 05:26 PM, Littlefield, Tyler wrote: Hello all: I have a basic server I am working on, and wanted some input with an error I'm getting. I am initializing the logger like so: if __name__ == __main__: observer = log.PythonLoggingObserver() observer.start()

Re: Daemon management

2011-12-27 Thread Lie Ryan
On 12/27/2011 12:43 PM, Fredrik Tolf wrote: Dear list, Lately, I've had a personal itch to scratch, in that I run a couple of Python programs as daemons, and sometimes want to inspect or alter them in ad-hoc ways, or other times need to do things to them that are less ad-hoc in nature, but

Re: Python education survey

2011-12-27 Thread Lie Ryan
On 12/28/2011 03:37 AM, Rick Johnson wrote: My logic is this: Including an IDE in the stdlib may have been a bad idea (although i understand and support Guido's original vision for IDLE). But since we do have it, we need to either MAINTAIN the package or REMOVE it. We cannot just stick our

Re: Python education survey

2011-12-27 Thread Lie Ryan
On 12/27/2011 10:41 PM, Eelco wrote: *Your suggestion of VIM is especially objectionable. Though I am sure it is a great tool to you, the subject here is beginner education. Just because it is a good tool for you, does not make it a good tool for a beginner. Before using VIM, I used to use

Re: Python education survey

2011-12-27 Thread Lie Ryan
On 12/28/2011 05:11 AM, Rick Johnson wrote: On Dec 27, 11:50 am, Lie Ryanlie.1...@gmail.com wrote: In case you haven't realised it, it is pretty much impossible for a large open source project to die; even if Guido decided to remove IDLE from the standard library I don't remember stating

Re: Possible bug in string handling (with kludgy work-around)

2011-12-27 Thread Lie Ryan
On 12/28/2011 05:04 AM, Rick Johnson wrote: -- Note: superfluous indention removed for clarity! -- On Dec 27, 8:53 am, Dennis Lee Bieberwlfr...@ix.netcom.com wrote: You can get by without the backslash in this situation too, by using triple quoting: I would not do that because: 1. Because

Re: Plot seems weird

2011-12-26 Thread Lie Ryan
On 12/26/2011 05:27 AM, Yigit Turgut wrote: On Dec 25, 7:06 pm, Rick Johnsonrantingrickjohn...@gmail.com wrote: On Dec 25, 9:33 am, Yigit Turguty.tur...@gmail.com wrote: Hi all, I have a text file as following; 0.2000470.00 0.2000530.16 0.2000590.00

Re: Backslash Escapes

2011-12-26 Thread Lie Ryan
On 12/26/2011 12:04 PM, Felipe O wrote: Hi all, Whenever I take any input (raw_input, of course!) or I read from a file, etc., any backslashes get escaped automatically. Python never escapes backslashes when reading from raw_input or files. Python only ever escapes backslashes when displaying

Re: Plot seems weird

2011-12-26 Thread Lie Ryan
On 12/27/2011 04:08 AM, Yigit Turgut wrote: On Dec 26, 11:28 am, Lie Ryanlie.1...@gmail.com wrote: On 12/26/2011 05:27 AM, Yigit Turgut wrote: On Dec 25, 7:06 pm, Rick Johnsonrantingrickjohn...@gmail.comwrote: On Dec 25, 9:33 am, Yigit Turguty.tur...@gmail.comwrote: Hi all,

Re: confused about __new__

2011-12-26 Thread Lie Ryan
On 12/27/2011 04:48 PM, Fredrik Tolf wrote: On Mon, 26 Dec 2011, K. Richard Pixley wrote: I don't understand. Can anyone explain? I'm also a bit confused about __new__. I'd very much appreciate it if someone could explain the following aspects of it: * The manual

Re: Test None for an object that does not implement ==

2011-12-25 Thread Lie Ryan
On 12/25/2011 08:38 PM, Nobody wrote: nothing should compare equal to None except for None itself, so x is None and x == None shouldn't produce different results unless there's a bug in the comparison method. not necessarily, for example: import random class OddClass: def __eq__(self,

Re: Test None for an object that does not implement ==

2011-12-25 Thread Lie Ryan
On 12/26/2011 01:13 AM, Roy Smith wrote: In articlemailman.4066.1324820148.27778.python-l...@python.org, Chris Angelicoros...@gmail.com wrote: On Mon, Dec 26, 2011 at 12:17 AM, Roy Smithr...@panix.com wrote: Just for fun, I tried playing around with subclassing NoneType and writing an

Re: what does 'a=b=c=[]' do

2011-12-24 Thread Lie Ryan
On 12/22/2011 10:20 AM, Dennis Lee Bieber wrote: which is to define the names a, b, and c, and connects the three names to the single object (integer 7 or new empty list). note that this connects and disconnecting business is more commonly referred to in python parlance as binding a name to

Re: Early and late binding [was Re: what does 'a=b=c=[]' do]

2011-12-24 Thread Lie Ryan
On 12/24/2011 07:25 PM, Steven D'Aprano wrote: I'd use a function attribute. def func(x, y=None): if y is None: y = func.default_y ... func.default_y = [] That's awkward only if you believe function attributes are awkward. I do. All you've done is move the default from *before*

Re: how to run python-script from the python promt? [absolute newbie]

2011-12-19 Thread Lie Ryan
On 12/19/2011 12:16 AM, nukeymusic wrote: On 18 dec, 13:39, Lie Ryanlie.1...@gmail.com wrote: On 12/18/2011 10:00 PM, nukeymusic wrote: How can I load a python-script after starting python in the interactive mode? I tried with load 'myscript.py' myscript.py myscript but none of

Re: how to run python-script from the python promt? [absolute newbie]

2011-12-18 Thread Lie Ryan
On 12/18/2011 10:00 PM, nukeymusic wrote: How can I load a python-script after starting python in the interactive mode? I tried with load 'myscript.py' myscript.py myscript but none of these works, so the only way I could work further until now was copy/paste line per line of my python-script

Re: calculate difference between two timestamps [newbie]

2011-12-18 Thread Lie Ryan
On 12/18/2011 10:43 PM, Peter Otten wrote: nukeymusic wrote: On 17 dec, 12:20, Günther Dietrichgd.use...@spamfence.net wrote: nukeymusicnukeymu...@gmail.com wrote: I'm trying to calculate the difference in seconds between two [...] import datetime date1 =

Re: Make a small function thread safe

2011-12-16 Thread Lie Ryan
On 12/17/2011 01:30 AM, Brad Tilley wrote: Or perhaps run should look like this instead: def run(t): lock.acquire() shared_container.append(t.name http://t.name) lock.release() That seems a bit barbaric to me, not sure. change that to: def run(t): with

Re: root[:]=[root,root]

2011-12-16 Thread Lie Ryan
On 12/17/2011 01:40 PM, YAN HUA wrote: Hi,all. Could anybody tell how this code works? root = [None, None] First, you're creating a list of two None, let's say it's list-1. Then you bind the name 'root' to list-1. root[:] = [root, root] Next, you assign list-1's first member with

Re: AttributeError in with statement (3.2.2)

2011-12-14 Thread Lie Ryan
On 12/15/2011 03:56 AM, Eric Snow wrote: On Tue, Dec 13, 2011 at 11:05 PM, Eric Snowericsnowcurren...@gmail.com wrote: If you want to be more dynamic about it you can do it, but it involves black magic. Chances are really good that being explicit through your class definition is the right

Re: Misleading error message of the day

2011-12-10 Thread Lie Ryan
On 12/09/2011 03:57 PM, alex23 wrote: On Dec 9, 11:46 am, Lie Ryanlie.1...@gmail.com wrote: perhaps the one that talks about `a, a.foo = 1, 2` blowing up? Are you sure you're not confusing this with the recent thread on 'x = x.thing = 1'? Ah, yes I do --

Re: order independent hash?

2011-12-10 Thread Lie Ryan
On 12/09/2011 10:27 PM, Steven D'Aprano wrote: On Thu, 08 Dec 2011 10:30:01 +0100, Hrvoje Niksic wrote: In a language like Python, the difference between O(1) and O(log n) is not the primary reason why programmers use dict; they use it because it's built-in, efficient compared to alternatives,

Re: order independent hash?

2011-12-10 Thread Lie Ryan
On 12/11/2011 11:17 AM, Chris Angelico wrote: On Sun, Dec 11, 2011 at 10:58 AM, Lie Ryanlie.1...@gmail.com wrote: On 12/09/2011 10:27 PM, Steven D'Aprano wrote: Except for people who needed dicts with tens of millions of items. who should be using a proper DBMS in any case. Not

Re: Need some IPC pointers

2011-12-08 Thread Lie Ryan
On 12/01/2011 08:03 AM, Andrew Berg wrote: I've done some research, but I'm not sure what's most appropriate for my situation. What I want to do is have a long running process that spawns processes (that aren't necessarily written in Python) and communicates with them. The children can be

Re: Misleading error message of the day

2011-12-08 Thread Lie Ryan
On 12/09/2011 07:13 AM, Ethan Furman wrote: Jean-Michel Pichavant wrote: You have to opportunity to not use unpacking anymore :o) There is a recent thread were the dark side of unpacking was exposed. Unpacking is a cool feautre for very small applications but should be avoided whenever possible

Re: subprocess.Popen under windows 7

2011-12-08 Thread Lie Ryan
On 12/09/2011 09:41 AM, Frank van den Boom wrote: What can I do, to prevent pressing the return key? I didn't have Windows 7 right now, but that shouldn't happen with the code you've given; when trimming code for posting, you should check that the trimmed code still have the exact same

Re: 70% [* SPAM *] multiprocessing.Queue blocks when sending large object

2011-12-05 Thread Lie Ryan
On 11/30/2011 06:09 AM, DPalao wrote: Hello, I'm trying to use multiprocessing to parallelize a code. There is a number of tasks (usually 12) that can be run independently. Each task produces a numpy array, and at the end, those arrays must be combined. I implemented this using Queues

Re: Fwd: class print method...

2011-12-05 Thread Lie Ryan
On 12/05/2011 10:18 PM, Suresh Sharma wrote: Pls help its really frustrating -- Forwarded message -- From: Suresh Sharma Date: Monday, December 5, 2011 Subject: class print method... To: d...@davea.name mailto:d...@davea.name d...@davea.name mailto:d...@davea.name Dave, Thanx

Re: Install Python on Windows without Start Menu icons?

2011-12-05 Thread Lie Ryan
On 12/05/2011 07:01 PM, Wolfgang Strobl wrote: Pedro Henrique G. Soutopedro.h.so...@gmail.com: On 02/12/2011 16:34, snorble wrote: Is it possible to automate the Python installation on Windows using the MSI file so it does not add a Start Menu folder? I would like to push out Python to all of

Re: order independent hash?

2011-12-04 Thread Lie Ryan
On 12/02/2011 03:29 PM, 8 Dihedral wrote: I clear my point a hash is a collection of (key, value) pairs that have well defined methods and behavior to be used in programming. The basic operations of a hash normally includes the following: 1. insertion of a (key, value) pair into the hash

Re: order independent hash?

2011-12-04 Thread Lie Ryan
On 12/02/2011 04:48 PM, 8 Dihedral wrote: On Friday, December 2, 2011 1:00:10 PM UTC+8, Chris Angelico wrote: On Fri, Dec 2, 2011 at 3:29 PM, 8 Dihedral dihedr...@googlemail.com wrote: I clear my point a hash is a collection of (key, value) pairs that have well defined methods and

Re: order independent hash?

2011-12-04 Thread Lie Ryan
On 12/05/2011 11:52 AM, 8 Dihedral wrote: On Monday, December 5, 2011 7:24:49 AM UTC+8, Ian wrote: On Sun, Dec 4, 2011 at 4:17 PM, 8 Dihedral dihedr...@googlemail.com wrote: Please explain what you think a hash function is, then. Per Wikipedia, A hash function is any algorithm or

Re: How to mix-in __getattr__ after the fact?

2011-11-07 Thread Lie Ryan
On 10/31/2011 11:01 PM, dhyams wrote: Thanks for all of the responses; everyone was exactly correct, and obeying the binding rules for special methods did work in the example above. Unfortunately, I only have read-only access to the class itself (it was a VTK class wrapped with SWIG), so I had

Re: Python ORMs Supporting POPOs and Substituting Layers in Django

2011-11-07 Thread Lie Ryan
On 11/08/2011 01:21 PM, Travis Parks wrote: On Nov 7, 12:44 pm, John Gordongor...@panix.com wrote: Inj98tnf$qh...@reader1.panix.com John Gordongor...@panix.com writes: In415d875d-bc6d-4e69-bcf8-39754b450...@n18g2000vbv.googlegroups.com Travis Parksjehugalea...@gmail.com writes: Which

Re: Question about 'iterable cursors'

2011-11-07 Thread Lie Ryan
On 11/07/2011 05:04 PM, John Nagle wrote: Realize that SQLite is not a high-performance multi-user database. You use SQLite to store your browser preferences, not your customer database. I agree with SQLite is not multi-user; I disagree that SQLite is not a high-performance database. In

Re: Convert DDL to ORM

2011-10-29 Thread Lie Ryan
On 10/25/2011 03:30 AM, Alec Taylor wrote: Good morning, I'm often generating DDLs from EER-Logical diagrams using tools such as PowerDesigner and Oracle Data Modeller. I've recently come across an ORM library (SQLalchemy), and it seems like a quite useful abstraction. Is there a way to

Re: How to mix-in __getattr__ after the fact?

2011-10-28 Thread Lie Ryan
On 10/29/2011 05:20 AM, Ethan Furman wrote: Python only looks up __xxx__ methods in new-style classes on the class itself, not on the instances. So this works: 8 class Cow(object): pass def attrgetter(self, a): print CAUGHT:

Re: Dynamically creating properties?

2011-10-27 Thread Lie Ryan
On 10/28/2011 08:48 AM, DevPlayer wrote: On Oct 27, 3:59 pm, Andy Dingleyding...@codesmiths.com wrote: I have some XML, with a variable and somewhat unknown structure. I'd like to encapsulate this in a Python class and expose the text of the elements within as properties. How can I

Re: Using decorators with argument in Python

2011-06-28 Thread Lie Ryan
On 06/29/2011 02:52 AM, Jigar Tanna wrote: coming across to certain views from people, it is not a good practice to use decorators with arguments (i.e. @memoize() ) and instead it is good to just use @memoize. Can any of you guys explain me advantages and disadvantages of using each of

Re: Python and Lisp : car and cdr

2011-06-19 Thread Lie Ryan
On 06/18/11 00:45, Franck Ditter wrote: Hi, I'm just wondering about the complexity of some Python operations to mimic Lisp car and cdr in Python... def length(L) : if not L : return 0 return 1 + length(L[1:]) Should I think of the slice L[1:] as (cdr L) ? I mean, is the slice a

Re: How to iterate on a changing dictionary

2011-06-19 Thread Lie Ryan
On 06/20/11 00:32, TheSaint wrote: Hello Trying to pop some key from a dict while is iterating over it will cause an exception. How I can remove items when the search result is true. Example: while len(dict): for key in dict.keys(): if dict[key] is not my_result:

Re: threading : make stop the caller

2011-06-19 Thread Lie Ryan
On 06/20/11 02:52, Laurent Claessens wrote: Popping task off the end of the list is more efficient: while task_list: task_list.pop().start() That's cool. In my case it's better to do task_list.pop(0).start in order to pop the first element. then you really wanted a queue instead

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile to Improvethe Dvorak Layout?

2011-06-18 Thread Lie Ryan
On 06/18/11 03:53, Xah Lee wrote: On Jun 15, 5:43 am, rusi rustompm...@gmail.com wrote: On Jun 15, 5:32 pm, Dotan Cohen dotanco...@gmail.com wrote: Thanks. From testing small movements with my fingers I see that the fourth finger is in fact a bit weaker than the last finger, but more

Re: Keyboard Layout: Dvorak vs Colemak: is it Worthwhile toImprovethe Dvorak Layout?

2011-06-18 Thread Lie Ryan
On 06/19/11 15:14, rusi wrote: On Jun 19, 9:21 am, Lie Ryan lie.1...@gmail.com wrote: On 06/18/11 03:53, Xah Lee wrote: On Jun 15, 5:43 am, rusi rustompm...@gmail.com wrote: On Jun 15, 5:32 pm, Dotan Cohen dotanco...@gmail.com wrote: Thanks. From testing small movements with my fingers I

Re: Fun python 3.2 one-liner

2011-04-08 Thread Lie Ryan
On 04/06/11 01:07, Steven D'Aprano wrote: On Tue, 05 Apr 2011 15:38:28 +0200, Daniel Fetchinson wrote: Personally, I find that the discipline of keeping to 80 characters is good for me. It reduces the temptation of writing obfuscated Python one- liners when two lines would be better. The

Re: Guido rethinking removal of cmp from sort method

2011-04-08 Thread Lie Ryan
On 04/09/11 01:08, Aahz wrote: Actually, my take is that removing __cmp__ was a mistake. (I already argued about it back in python-dev before it happened, and I see little point rehashing it. My reason is strictly efficiency grounds: when comparisons are expensive -- such as Decimal object

  1   2   3   4   5   6   7   8   >