Re: Why is lambda allowed as a key in a dict?

2009-03-10 Thread Craig Allen
> I think the point is that function objects compare by object identity, > so the two lambdas you use above are not equal even though they have the > same code. it raises an interesting question about why doesn't it. I can think of practical answers to that, obviously, but in principle, if a fun

Re: Is python worth learning as a second language?

2009-03-10 Thread Craig Allen
On Mar 9, 12:43 am, ZikO wrote: > Hi > > I hope I won't sound trivial with asking my question. > > I am a C++ programmer and I am thinking of learning something else > because I know second language might be very helpful somehow. I have > heard a few positive things about Python but I have never w

Re: Ban Xah Lee

2009-03-11 Thread Craig Allen
> There you go: a 30-second psychological diagnosis by an > electrical engineer based entirely on Usenet postings.  It > doesn't get much more worthless than that... > > -- > Grant rolf but interesting post nonetheless. I have been really somewhat fascinated by AS since I heard of it about a dec

Re: Why is lambda allowed as a key in a dict?

2009-03-11 Thread Craig Allen
On Mar 10, 1:39 pm, Paul Rubin <http://[email protected]> wrote: > Craig Allen writes: > > it raises an interesting question about why doesn't it.  I can think > > of practical answers to that, obviously, but in principle, if a > > function compiles to

packaging

2009-03-17 Thread Craig Allen
we have software we are putting into package form. So far, all the code was in local py files and we imported between the modules as you'd think. Now with the package ("ourpackage") we are addressing how import affects the importing module. if "ourpackage" __init__.py itself does regular imports

Re: packaging

2009-03-18 Thread Craig Allen
> andrew thanks andrew, good advice, I should probably use that throughout our code. btw, hope the world is treating you well, long time no see... -craig -- http://mail.python.org/mailman/listinfo/python-list

Re: Beazley on Generators

2009-04-01 Thread Craig Allen
this is great, thanks... we have used generators to create something akin to a cooperative tasking environment... not to implement multitasking, but to be able to control low level data processing scripts. These scripts, written as generators, yield control to a control loop which then can pause,

Project source code layout?

2009-06-03 Thread Allen Fowler
ovide the various config settings to both the web app and scripts. Any suggestions? ideas? fwiw, I am planing on keeping the whole thing in a Mercurial repository. Thank you, Allen :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Project source code layout?

2009-06-03 Thread Allen Fowler
> > I'm new to Python, and am looking for some suggestions as to the source > > code layout for a new project. > > Is this the development layout or the deployment layout? The two need not > bear any resemblance. > Looking for suggestions on both. I was hoping to keep the dev layout as clo

Re: Project source code layout?

2009-06-04 Thread Allen Fowler
ns: 1) Do you use virtualpython? 2) How do you load the modules in your lib directory? 3) How do you reference your configuration directives from within your modules and CGI/daemon scripts? Thank you, Allen -- http://mail.python.org/mailman/listinfo/python-list

Re: Python is slow

2008-06-07 Thread Sean Allen
On May 24, 2008, at 1:56 AM, cm_gui wrote: okay, maybe Python is only slightly slower than PHP, but it APPEARS to be much slower. there is a distinct waiting time whenever you access a python web page before the page starts loading. but once it loads, it is fast. php page starts loading immedi

singletons

2008-07-16 Thread Craig Allen
Hey, forgive me for just diving in, but I have a question I was thinking of asking on another list but it really is a general question so let me ask it here. It's about how to approach making singletons. Background: I've been programming in python seriously for about a year now, maybe a little lon

Re: singletons

2008-07-16 Thread Craig Allen
al is still that tl = TehLibrary() would always return the same object. -craig On Jul 16, 2:00 pm, castironpi <[EMAIL PROTECTED]> wrote: > On Jul 16, 5:20 pm, Craig Allen <[EMAIL PROTECTED]> wrote: > > > > > Hey, forgive me for just diving in, but I have a question I was &g

Re: singletons

2008-07-17 Thread Craig Allen
On Jul 16, 7:01 pm, Lawrence D'Oliveiro <[EMAIL PROTECTED] central.gen.new_zealand> wrote: > In message > <[EMAIL PROTECTED]>, Craig > > Allen wrote: > > ... the ideal is still that > > > tl = TehLibrary() would always return t

Re: singletons

2008-07-17 Thread Craig Allen
On Jul 17, 2:15 am, Uwe Schmitt <[EMAIL PROTECTED]> wrote: > On 17 Jul., 00:20, Craig Allen <[EMAIL PROTECTED]> wrote: > > > > > I have several classes in our system which need to act like > > singletons, they are libraries of data classifications, and other

Re: singletons

2008-07-18 Thread Craig Allen
On Jul 17, 9:04 pm, Paddy <[EMAIL PROTECTED]> wrote: > On Jul 16, 11:20 pm, Craig Allen <[EMAIL PROTECTED]> wrote: > > > Hey, forgive me for just diving in, but I have a question I was > > thinking of asking on another list but it really is a general question > >

Re: Python Written in C?

2008-07-21 Thread Craig Allen
it's clear to me that the perfect language should exist a priori, coming to being causa sui. Having to actually implement a language is disgusting and unnatural. -- http://mail.python.org/mailman/listinfo/python-list

when does the GIL really block?

2008-07-31 Thread Craig Allen
I have followed the GIL debate in python for some time. I don't want to get into the regular debate about if it should be gotten rid of (though I am curious about the status of that for Python 3)... personally I think I can do multi-threaded programming well, but I also see the benefits of a multi

Re: when does the GIL really block?

2008-08-01 Thread Craig Allen
On Aug 1, 12:06 pm, Rhamphoryncus <[EMAIL PROTECTED]> wrote: > On Jul 31, 7:27 pm, Craig Allen <[EMAIL PROTECTED]> wrote: > > > > > I have followed the GIL debate in python for some time. I don't want > > to get into the regular debate about if it should

Re: when does the GIL really block?

2008-08-04 Thread Craig Allen
On Aug 1, 2:28 pm, John Krukoff <[EMAIL PROTECTED]> wrote: > On Thu, 2008-07-31 at 18:27 -0700, Craig Allen wrote: > > I have followed the GIL debate in python for some time. I don't want > > to get into the regular debate about if it should be gotten rid of > >

Re: Is my thinking Pythonic?

2008-08-21 Thread Craig Allen
generally, I name the members in the Class definition and set them to None there... class Car: speed = None brand = None def __init__(): self.speed = defaultspeed #alternately, and more commonly, get this speed as a initializer argument self.brand = defaultbrand That solves

Re: When to use try and except?

2008-08-29 Thread Craig Allen
On Aug 29, 7:23 am, cnb <[EMAIL PROTECTED]> wrote: > If I get zero division error it is obv a poor solution to do try and > except since it can be solved with an if-clause. > > However if a program runs out of memory I should just let it crash > right? Because if not then I'd have to write exceptio

Re: How to record audio from Python on Mac?

2008-09-09 Thread Craig Allen
I want to do this as well, and also some other audio processing via python. I have not tried yet, but much of my research points to pyaudio, PortAudio bindings for python, which is supposed to be multi- platform including Mac OS X, but as I say, I've not tried it yet. Related to this are some exa

Re: Adding environment variables to bash.

2008-09-11 Thread Craig Allen
On Sep 11, 10:25 am, nntpman68 <[EMAIL PROTECTED]> wrote: > >> doesn't exactly work for Python scripts, though: > > >> $ cat env.py > >> #!/usr/bin/env python > >> import os > >> os.environ["TEST"] = "hello" > > >> $ . ./env.py && env | grep TEST > >> import: unable to open X server `'. > >> bash:

Re: What do you call a class not intended to be instantiated

2008-09-22 Thread Craig Allen
> Snce when are "users" ever involved > in programming problems or programming > languages ? > since the begining, the first users are programmers, users of your libraries. -- http://mail.python.org/mailman/listinfo/python-list

Re: Not fully OO ?

2008-09-22 Thread Craig Allen
It is clear to me that Python is a multiparadigmed object oriented language. It is clearly possible to write procedural code... that is, Python does not force object oriented syntax or concepts on you and insist you define everything in such a structure. Is the OO it allows full OO, I think so, an

Re: Not fully OO ?

2008-09-23 Thread Craig Allen
> if they want to, but it is *fully* OO in that it includes everything > required to do OO. But maybe the original blogger meant by "fully OO" > what I mean by "Pure OO"? it seems to me this is what was meant... pure OO, AND forced to use it. My personal feeling is that python is multiparadigmed

Re: What do you call a class not intended to be instantiated

2008-09-23 Thread Craig Allen
> > > Usegrammers? > usegrammers are just those that use grammars, but misspell it. -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are "broken iterators" broken?

2008-09-23 Thread Craig Allen
I'm interested what others think of this because at first I couldn't get it... I have an object which can iterate over its parts... and at first I thought, what? I'm supposed to create a new object every time the user needs to iterate the contents? In the end I interpreted that statement as if "un

Re: Python style: exceptions vs. sys.exit()

2008-09-23 Thread Craig Allen
> The > question is: should the library function be able to just dump to > sys.exit() with a message about the error (like "couldn't open this > file"), or should the exception propagate to the calling program which > handles the issue? > my view is that the exceptions are there precisely to tell

Re: Python style: exceptions vs. sys.exit()

2008-09-24 Thread Craig Allen
> Why, yes, I am wearing my BOFH hat. How could you tell? > > -- > Tim Rowe evil, but I think you may be a BSEFH, not a BOFH. -- http://mail.python.org/mailman/listinfo/python-list

SPECIAL DISCOUNTS - Online Python Training

2008-09-29 Thread Jeanne Allen
* Nov 19: Spring Security to Secure your Java Web Application http://www.dashcourses.com/contests/dashconnect.html Check out our full schedule of online classes! Project Management, Java, PCI, USB, Perl, Python.and much, much more http://www.dashcourses.com/public-courses.html Si

Re: [Twisted-Python] ANN: Twisted 9.0.0

2009-12-02 Thread Tim Allen
[email protected] wrote: > A message with some ticket links from a thread on the twisted-python > mailing list: http://bit.ly/8csFSa Some of those tickets seem out of date; a better plan would be to query for tickets with the "py3k" keyword: http://twistedmatrix.com/trac/search?q=py3

SimpleXMLRPCServer daemon

2010-01-29 Thread Thomas Allen
e if it were deleted reliably. Thomas Allen -- http://mail.python.org/mailman/listinfo/python-list

unicode-to-ascii: replace with space, not "?"

2009-10-14 Thread Allen Fowler
Hello, I've been using "data.encode('ascii','replace')" to force an ASCII string out of Unicode data, with "?" in the place of non-ASCII letters. However, now I want to use a blank space (or maybe a dash) instead of a question mark. How do I do this? Thank you, :) -- http://mail.py

Re: method to intercept string formatting % operations

2010-02-05 Thread Brad Allen
On Fri, Feb 5, 2010 at 9:49 AM, Jean-Michel Pichavant wrote: > Anyway why would you want to use the tuple form ? it's beaten in every > aspect by the dictionary form. I'm subclassing a namedtuple, and adding some additional functionality such as __getitem__, __setitem__, so that the namedtuple a

Re: Have you embraced Python 3.x yet?

2010-03-28 Thread Ray Allen
In our company, we still use python-2.5.4, and will be updated to python-2.5.5. I hope we can go to 2.6.x or 3.x, but I'm not sure when. -- http://mail.python.org/mailman/listinfo/python-list

Re: Good Intermediate Tutorials

2010-04-01 Thread Ray Allen
programs. If you want to know more you can read the cpython source itself. Its not too difficult. -- Ray Allen Best wishes! -- http://mail.python.org/mailman/listinfo/python-list

Re: Python's equivalent to Main calling program and subprograms

2010-12-01 Thread Bill Allen
Thanks for the explanation of "main". Some tutorials mention it, some don't. I have written some not trial Python programs and have never had a real need to use that convention, but at least I understand it now. --Bill On Wed, Dec 1, 2010 at 1:13 PM, Tim Harig wrote: > > On Wed, Dec 1, 2010

Re: Python on wikipedia

2010-12-12 Thread Bill Allen
Yeah, I noticed that a while back too. Kinda cool. --Bill On Sun, Dec 12, 2010 at 3:21 PM, DevPlayer wrote: > Snapshot in time, hey look at that; someone used Python as THE example > of what a programming language is on Wikipedia. > http://en.wikipedia.org/wiki/Programming_language > -- > htt

Re: Which is the best book to learn python

2011-02-14 Thread Bill Allen
Alan Gauld has written a very good online book called Learning to Program. I would definitely recommend it. http://www.alan-g.me.uk/l2p/index.htm -Bill On Mon, Jan 24, 2011 at 11:09, santosh hs wrote: > Hi All, > i am beginner to python please tell me which is the best available > referenc

[Python-list] The distutils.sysconfig.set_python_config() function

2010-04-09 Thread Ray Allen
find it in distutils/sysconfig.py. Thanks. -- Ray Allen Best wishes! -- http://mail.python.org/mailman/listinfo/python-list

Access class from staticmethod

2010-04-30 Thread Thomas Allen
Is that possible? class A(object): @staticmethod def set_b(x): # A.b = x, without knowing A is "A" pass Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Access class from staticmethod

2010-04-30 Thread Thomas Allen
Ah ha, @classmethod. On Apr 30, 3:47 pm, Thomas Allen wrote: > Is that possible? > > class A(object): >   @staticmethod >   def set_b(x): >     # A.b = x, without knowing A is "A" >     pass > > Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: convert time to UTC seconds since epoch

2010-07-21 Thread Steve Allen
On Jul 20, 6:57 pm, Chris Rebert wrote: [regarding trust of POSIX vis a vis leap seconds] > I'm not saying they necessarily should, but they're standardized and > the `time` module is based on POSIX/Unix-ish assumptions; not > following POSIX would be inconsistent and problematic. > Breaking stand

Re: Python simple web development

2009-06-26 Thread Thomas Allen
On Jun 25, 3:29 am, Private Private wrote: > Hi, > > I am looking for a python library which will allow me to do a simple > web development. I need to use > some forms (but nice looking :-) ), creating images based on input > from those forms, etc. I have read a bit about Django and TurboGears > b

XML(JSON?)-over-HTTP: How to define API?

2009-07-02 Thread Allen Fowler
I have an (in-development) python system that needs to shuttle events / requests around over the network to other parts of itself. It will also need to cooperate with a .net application running on yet a different machine. So, naturally I figured some sort of HTTP event / RPC type of would be

Re: XML(JSON?)-over-HTTP: How to define API?

2009-07-02 Thread Allen Fowler
> I have an (in-development) python system that needs to shuttle events / > requests > around over the network to other parts of itself. It will also need to > cooperate with a .net application running on yet a different machine. > > So, naturally I figured some sort of HTTP event / RPC t

multiprocessing: Correct usage of pool & queue?

2009-09-04 Thread Allen Fowler
Hello, I have a list of tasks/items that I want handed off to threads/processes to complete. (I would like to stick with process if I could, since there is some CPU work here. ) Each task involves some calculations and a call to a remote server over urllib2/HTTP. The time to complete each ta

Scheduling algorithm: Suggestions?

2009-09-07 Thread Allen Fowler
Hello, I have a batch of "rpc style" calls that I must make to an external server via HTTP in a multi threaded fashion. (Return vales must be saved.) Problem is, I need to throttle the rate at which I do this. Each HTTP call takes between 0.2 and several seconds to complete. I need to contr

multiproccess: What is the Dameon flag?

2009-09-15 Thread Allen Fowler
Hello, What is the Daemon flag and when/why would I want to use it? Thank you, AF -- http://mail.python.org/mailman/listinfo/python-list

Re: multiproccess: What is the Dameon flag?

2009-09-15 Thread Allen Fowler
> > > > What is the Daemon flag and when/why would I want to use it? > > > From the documentation: "When a process exits, it attempts to terminate > all of its daemonic child processes.". > > Sometimes you want the main process to wait for its worker processes to > terminate before terminating

portable python

2017-04-28 Thread allen wade
is there a way to install python on a thumb drive that does not require an administrator's password? I have to use public computers and store all my applications to the thumb drive, using the Portable Apps Platform to manage the applications. -- https://mail.python.org/mailman/listinfo/python-lis

Procedure for downloading and Installing Python 2.7 Modules

2015-07-20 Thread W. D. Allen
Would like to locate and install numpy, scipy and matplotlib with Wing 101 for Python 2.7 Just beginning to use Python 2.7 for engineering work. Any guidance would be appreciated. Thanks, WDA [email protected] end -- https://mail.python.org/mailman/listinfo/python-list

Which Pyton Book For Newbies?

2006-07-22 Thread W. D. Allen
I want to write a retirement financial estimating program. Python was suggested as the easiest language to use on Linux. I have some experience programming in Basic but not in Python. I have two questions: 1. What do I need to be able to make user GUIs for the program, and 2. Which book would

Tkinter canvas size determination

2006-02-22 Thread Dean Allen Provins
I need to determine the size of a canvas while the process is running. Does anyone know of a technique that will let me do that? Thanks, Dean -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter canvas size determination

2006-02-22 Thread Dean Allen Provins
Cameron Laird wrote: > In article <[EMAIL PROTECTED]>, > Dean Allen Provins <[EMAIL PROTECTED]> wrote: > >>I need to determine the size of a canvas while the process is running. >>Does anyone know of a t

Re: Tkinter canvas size determination

2006-02-24 Thread Dean Allen Provins
Cameron: Cameron Laird wrote: > In article <[EMAIL PROTECTED]>, > Dean Allen Provins <[EMAIL PROTECTED]> wrote: > >>I need to determine the size of a canvas while the process is running. >>Does anyone know of a t

Re: Tkinter canvas size determination

2006-02-24 Thread Dean Allen Provins
Martin: Martin Franklin wrote: > Dean Allen Provins wrote: > >> Cameron: >> >> Cameron Laird wrote: >> >>> In article <[EMAIL PROTECTED]>, >>> Dean Allen Provins <[EMAIL PROTECTED]> wrote: >>> >>>> I need to determ

Re: Binary search tree

2007-11-13 Thread Scott Sandeman-Allen
On 11/13/07, Terry Reedy ([EMAIL PROTECTED]) wrote: >"Scott SA" <[EMAIL PROTECTED]> wrote in message >news:[EMAIL PROTECTED] >| On 11/12/07, Scott SA ([EMAIL PROTECTED]) wrote: >| I decided to test the speeds of the four methods: >| >|set_example >|s = set() >|for url in urls

Re: Photo gallery software

2008-05-01 Thread Scott Sandeman-Allen
On 5/1/08, Jumping Arne ([EMAIL PROTECTED]) wrote: >I've searching for some software that would allow me to present my photos on >the web (I'm not interested a software that generates static pages that I >upload) and there are quite a few, see for example >

Re: Milenko Kindl rtegdgd

2008-09-21 Thread James Dow Allen
; > I don't know why, but that's the way it works. I recall a befuddled ESL student who missed a question based on "Isn't that girl pretty?" "Isn't she!!" James Hussein Allen -- http://mail.python.org/mailman/listinfo/python-list

printing under MS win

2006-03-30 Thread Dean Allen Provins
Hi: My Linux-based Python/Tkinter application runs nicely, and printing works just fine (to a user-selected file, or an "lpr" device specified in the Entry box). Alas, the user wants to run it under MS Win, and of course will want to print the canvas for posterity. A Google search turned up a si

Re: printing under MS win

2006-03-30 Thread Dean Allen Provins
Tim Golden wrote: > [Dean Allen Provins] > > | My Linux-based Python/Tkinter application runs nicely, and printing > | works just fine (to a user-selected file, or an "lpr" device specified > | in the Entry box). Alas, the user wants to run it under MS > | Win, an

Python threading

2009-01-13 Thread Brian Allen Vanderburg II
I'm doing some multi-threaded programming and before diving into the C/C++ code I though I'd do some in Python first. I decided to read through the threading module and I understand some of it, but I don't understand this, though I'm sure it is easy: The condition object has a method _is_owne

Re: Does Python really follow its philosophy of "Readability counts"?

2009-01-14 Thread Brian Allen Vanderburg II
[email protected] wrote: Here is a piece of C code this same guy showed me saying Pythonic indention would make this hard to read -- Well lets see then! I swear, before god, this is the exact code he showed me. If you don't believe me i will post a link to the thread. // Warning ugly C code ahe

Re: USB in python

2009-01-22 Thread Brian Allen Vanderburg II
[email protected] wrote: Hi, Im trying to write a program for my USB device and I'm thinking of using python to do this. The USB device is of my own making and it is activated when one of the two data pins of the USB is given about 5V (or similar to whatever the power pin is getting). Now I

Re: pep 8 constants

2009-01-22 Thread Brian Allen Vanderburg II
[email protected] wrote: Constants would be a nice addition in python, sure enough. But I'm not sure that this can be done without a run-time check every time the constant is used, and python is already slow enough. Maybe a check that is disabled when running with optimizing flags ? But I'm su

Idea to support public/private.

2009-01-22 Thread Brian Allen Vanderburg II
Okay so I don't really care about public/private but I was watching the lists (Does python follow its idea of readability or something like that) and I thought of a 'possible' way to add this support to the language. I have implemented a class which allows creating both a private as well as a

Re: Idea to support public/private.

2009-01-22 Thread Brian Allen Vanderburg II
There was a small error in setprivate/getprivate: import sys import inspect def get_private_codes(class_): codes = [] for i in class_.__dict__: value = class_.__dict__[i] if inspect.isfunction(value): codes.append(value.func_code) return codes def get_protect

Re: USB in python

2009-01-22 Thread Brian Allen Vanderburg II
[email protected] wrote: Hi, Thanks for all the responses but I forgot to mention that I have very little hardware understanding (at least in english) and the device itself it very simple and only needs about 5V power to be active. The problem here is that I want to control when the device

Re: Dynamic methods and lambda functions

2009-01-23 Thread Brian Allen Vanderburg II
[email protected] wrote: class Person: def __init__(self): for prop in props: setattr(self, "__" + prop[0], prop[1]) setattr(Person, "Get" + prop[0], lambda self: getattr (self, "__" + prop[0])) I've had a similar problem here and here is best how I can ex

Re: How do I get my python program to get the root password ?

2009-01-23 Thread Brian Allen Vanderburg II
[email protected] wrote: On 2009-01-24, Linuxguy123 wrote: I want to make a python program that I can run as a normal user that changes the permission on some device files. It will need to ask me for the root password and then run chown as root in order to do this. How do I accomplish thi

Re: understanding nested lists?

2009-01-24 Thread Brian Allen Vanderburg II
[email protected] wrote: I have a short peace of code that is not doing what I expect. when I assign a value to a list in a list alist[2][4]=z this seems replace all the 4 elements in all the sub lists. I assume it is supposed to but this is not what I expect. How would I assign a value

Re: USB in python

2009-01-26 Thread Brian Allen Vanderburg II
[email protected] wrote: Tim Roberts wrote: Sorry, but you have NOT created a USB device, and I sincerely hope you do not try to plug it in to a real USB port. Sorry, by USB device, I meant a device that is powered/activated by a bunch of wires that I want to control using a computer and

Understanding descriptors

2009-01-29 Thread Brian Allen Vanderburg II
I'm trying to better understand descriptors and I've got a few questions still after reading some sites. Here is what I 'think', but please let me know if any of this is wrong as I'm sure it probably is. First when accessing an attribute on a class or instance it must be found. For an insta

Re: new.instancemethod questions

2009-01-29 Thread Brian Allen Vanderburg II
[email protected] wrote: On Jan 29, 7:38 pm, Mel wrote: schickb wrote: I'd like to add bound functions to instances, and found the instancemethod function in the new module. A few questions: 1. Why is instancemethod even needed? Its counter-intuitive (to me at least) that assig

Re: libsudo ?

2009-01-29 Thread Brian Allen Vanderburg II
[email protected] wrote: Does anyone know where I would find libsudo ? http://sourceforge.net/projects/libsudo If you had the choice of using pexpect or libsudo, which would you use ? libsudo does all the work for you of executing sudo, checking for the expected responses and all. I

Re: Why such different HTTP response results between 2.5 and 3.0

2009-02-01 Thread Brian Allen Vanderburg II
[email protected] wrote: Below are two semantically same snippets for querying the same partial HTTP response, for Python2.5 and Python 3.0 respectively. However, the 3.0 version returns a not-so-right result(msg) which is a bytes of length 239775, while the 2.5 version returns a good msg which is

Re: Understanding descriptors

2009-02-05 Thread Brian Allen Vanderburg II
[email protected] wrote: So the lookup chain is: 1/ lookup the class and bases for a binding descriptor 2/ then lookup the instance's __dict__ 3/ then lookup the class and bases for a non-binding descriptor or plain attribute 4/ then class __getattr__ Also and FWIW,

Re: Flattening lists

2009-02-05 Thread Brian Allen Vanderburg II
[email protected] wrote: Hello everybody, Any better solution than this? def flatten(x): res = [] for el in x: if isinstance(el,list): res.extend(flatten(el)) else: res.append(el) return res a = [1, 2, 3, [4, 5, 6], [[7, 8], [9, 10]]] print fl

Re: Flattening lists

2009-02-05 Thread Brian Allen Vanderburg II
[email protected] wrote: Baolong zhen wrote: less list creation. At the cost of doing this at each 'flatten' call: if res is None: res = [] The number of situations of executing above code is the same as the number of list creations (once for each 'flatten' call, obviously). Is list cre

Re: Converting numbers to words

2009-02-05 Thread Brian Allen Vanderburg II
[email protected] wrote: > > I've been trying to figure this out for over 2 hours and I'm really frustrated right now. > > I first made Python to ask user to input height in meters. If user puts certain value in meter, then it converts it to feet and inches as follows: > > > Enter the hei

Python idea/proposal to assist in single-archive python applications

2008-12-07 Thread Brian Allen Vanderburg II
Python Community The following is just an idea that I considered that may be helpful in creating an application in a single archive easier and with less code. Such an application would be similar to jar files for Java. First, the application and all data files should be able to run either e

Re: Python idea/proposal to assist in single-archive python applications

2008-12-07 Thread Brian Allen Vanderburg II
[EMAIL PROTECTED] wrote: Why not use pkgutil.get_data()? Provided you remember to put your zip file on PYTHONPATH you can already run modules directly out of a zipfile (Python 2.5 and later).If your zipfile contains __main__.py then with Python 2.6 or later you can run it directly: just spec

Re: How to initialize a class variable once

2008-12-09 Thread Brian Allen Vanderburg II
[EMAIL PROTECTED] wrote: Unless you are calling reload() on the module, it will only ever get _loaded_ once. Each additional import will just yield the existing module. Perhaps if you post an example of the behavior that leads you to believe that the class variables are getting reinitialized I c

Re: Bidirectional Networking

2008-12-13 Thread Brian Allen Vanderburg II
[email protected] wrote: On Dec 13, 11:13 pm, Bryan Olson wrote: Software firewalls will often simply refuse incoming connections. The basic protection of the garden-variety home router comes from "network address translation" (NAT), in which case TCP connections initiated from the inside wil

Limit traceback from most recent call

2008-12-14 Thread Brian Allen Vanderburg II
I've looked at traceback module but I can't find how to limit traceback from the most recent call if it is possible. I see that extract_tb has a limit parameter, but it limits from the start and not the end. Currently I've made my own traceback code to do this but wonder if python already has

Re: Limit traceback from most recent call

2008-12-15 Thread Brian Allen Vanderburg II
[email protected] wrote: On Dec 14, 8:07 pm, Brian Allen Vanderburg II wrote: Hi, The interface of extract_tb is: traceback.extract_tb(tb, limit=None) try to play with the 'limit' argument Good luck, Yinon -- http://mail.python.org/mailman/listinfo/python-list I hav

Re: Relative imports in Python 3.0

2008-12-17 Thread Brian Allen Vanderburg II
[email protected] wrote: Imagine a module that looks like ModuleDir __init__.py a.py b.py In python 2.x I used to have tests at the end of each of my modules, so that module b.py might look something like import a .. .. if __name__ == '__main__': run

Re: If programming languages were religions...

2008-12-19 Thread Brian Allen Vanderburg II
[email protected] wrote: very interesting http://www.aegisub.net/2008/12/if-programming-languages-were-religions.html "Python would be Humanism: It's simple, unrestrictive, and all you need to follow it is common sense. Many of the followers claim to feel relieved from all the burden impos

Copying objects and multiple inheritance

2009-06-02 Thread Brian Allen Vanderburg II
What is the best way to copy an object that has multiple inheritance with the copy module. Particularly, some of the instances in the hierarchy use the __copy__ method to create a copy (because even for shallow copies they need some information updated a little differently), so how can I mak

Re: Copying objects and multiple inheritance

2009-06-03 Thread Brian Allen Vanderburg II
Gabriel Genellina wrote: En Tue, 02 Jun 2009 19:02:47 -0300, Brian Allen Vanderburg II escribió: What is the best way to copy an object that has multiple inheritance with the copy module. Particularly, some of the instances in the hierarchy ("...some of the classes in...",

How to do relpath implementation on 2.5

2009-08-08 Thread Brian Allen Vanderburg II
I've coded my own 'relpath' implementation for 2.5 (shown below) and I want to make sure it follows as closely as it should to 2.6 and later. I've got a question regarding that. When attempting to convert to a relative path and it is not possible for some reason (different drive or UNC share)

Re: what is it, that I don't understand about python and lazy evaluation?

2009-08-13 Thread Brian Allen Vanderburg II
Erik Bernoth wrote: Hi List, look at the following code: def evens(): # iterator returning even numbers i = 0 while True: yield i i += 2 # now get all the even numbers up to 15 L = [n for n in evens() if n < 15] Isn't it strange, that this code runs (in a lazy lang

<    1   2