Re: [python] Re: GitHub's ³pull request² is proprietary lock-in

2016-01-03 Thread W. Trevor King
On Sun, Jan 03, 2016 at 04:31:55AM -0500, Random832 wrote: > But there is no command to create a "pull request", nowhere for such > a thing to exist in the repository, etc. There is this [1]. > Also if someone puts through a github pull request and then their > patch is accepted, my understanding

Async/Concurrent HTTP Requests

2015-02-12 Thread Ari King
Hi, I'd like to query two (or more) RESTful APIs concurrently. What is the pythonic way of doing so? Is it better to use built in functions or are third-party packages? Thanks. Best, Ari -- https://mail.python.org/mailman/listinfo/python-list

Validating Data Extracted from Files

2014-06-30 Thread Ari King
Hi, I'm sourcing data from multiple excel files (workbooks) each with multiple worksheets. Prior to persisting the aggregated data, I want to validate it. I was thinking of creating classes to hold the data and validate type and content via methods. I'd appreciate feedback on this approach, sug

Re: parametized unittest

2014-01-11 Thread W. Trevor King
On Sat, Jan 11, 2014 at 08:00:05PM -0800, CraftyTech wrote: > I'm finding it hard to use unittest in a for loop. Perhaps something like: > > for val in range(25): > self.assertEqual(val,5,"not equal) > > The loop will break after the first failure. Anyone have a good > approach for this? ple

Re: [python] email 8bit encoding

2013-07-29 Thread W. Trevor King
On Sun, Jul 28, 2013 at 04:41:27PM -0700, ru...@yahoo.com wrote: > How, using Python-3.3's email module, do I "flatten" (I think > that's the right term) a Message object to get utf-8 encoded > body with the headers: > Content-Type: text/plain; charset=UTF-8 > Content-Transfer-Encoding: 8bit > wh

CC etiquette for mailing lists (was: Don't feed the troll...)

2013-06-15 Thread W. Trevor King
On Sun, Jun 16, 2013 at 12:51:04AM +, Steven D'Aprano wrote: > On Sun, 16 Jun 2013 09:09:37 +1000, Chris Angelico wrote: > > Mailman is the software that runs python-list@python.org, so this > > *is* applicable to everyone who reads the mailing list (including > > myself). The fact that there'

Mailman forwarding (was: Don't feed the troll...)

2013-06-15 Thread W. Trevor King
On Sat, Jun 15, 2013 at 01:07:29PM -0400, D'Arcy J.M. Cain wrote: > On Sat, 15 Jun 2013 18:41:41 +0200 Chris “Kwpolska” Warrick wrote: > > On Sat, Jun 15, 2013 at 5:40 PM, Steven D'Aprano wrote: > > > In the name of all that's good and decent in the world, why on earth > > > would you do that when

How to Nest Structs?

2013-03-04 Thread Ari King
Hi, I'm trying to nest the "info_header", "info_body", and "info_trailer" structs (see below) into a "data_packet" struct. Does anyone know how I can/should accomplish this? Thanks. batch_header_format = struct.Struct('!c2h') info_header_format = struct.Struct('!2hl') mkt_status_format = struct

Flatten an email Message with a non-ASCII body using 8bit CTE

2013-01-24 Thread W. Trevor King
Hello list! I'm trying to figure out how to flatten a MIMEText message to bytes using an 8bit Content-Transfer-Encoding in Python 3.3. Here's what I've tried so far: # -*- encoding: utf-8 -*- import email.encoders from email.charset import Charset from email.generator import BytesGenerat

problem python

2012-06-06 Thread Tom King
hi im new in python and i have a problem about when i type python in my command line console i get an error message  'import site' failed; use -v for traceback Python 2.4.3 (#1, May  5 2011, 18:44:23) [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2 Type "help", "copyright", "credits" or "lice

Re: tiny script has memory leak

2012-05-17 Thread Iain King
On Friday, 11 May 2012 22:29:39 UTC+1, gry wrote: > sys.version --> '2.6 (r26:66714, Feb 21 2009, 02:16:04) \n[GCC 4.3.2 > [gcc-4_3-branch revision 141291]] > I thought this script would be very lean and fast, but with a large > value for n (like 15), it uses 26G of virtural memory, and things

Re: Python Gotcha's?

2012-04-05 Thread Iain King
A common one used to be expecting .sort() to return, rather than mutate (as it does). Same with .reverse() - sorted and reversed have this covered, not sure how common a gotcha it is any more. Iain On Wednesday, 4 April 2012 23:34:20 UTC+1, Miki Tebeka wrote: > Greetings, > > I'm going to

Re: Refactor/Rewrite Perl code in Python

2011-07-25 Thread J Kenneth King
Steven D'Aprano writes: > On Sun, Jul 24, 2011 at 7:29 PM, Shashwat Anand > wrote: > >> How do I start ? >> The idea is to rewrite module by module. >> But how to make sure code doesn't break ? > > By testing it. > > Read up on "test driven development". > > At this point, you have this: > > Per

Re: Functional style programming in python: what will you talk about if you have an hour on this topic?

2011-07-13 Thread J Kenneth King
Anthony Kong writes: > (My post did not appear in the mailing list, so this is my second try. > Apology if it ends up posted twice) > > Hi, all, > > If you have read my previous posts to the group, you probably have some idea > why I asked this question. > > I am giving a few presentations on p

Re: Code Review

2011-05-25 Thread Iain King
On May 25, 2:44 pm, ad wrote: > On May 25, 4:06 am, Ulrich Eckhardt > wrote: > > > > > ad wrote: > > > Please review the code pasted below. I am wondering what other ways > > > there are of performing the same tasks. > > > On a unix system, you would call "find" with according arguments and then

Re: use of index (beginner's question)

2011-04-28 Thread Iain King
On Apr 28, 2:45 am, Chris Angelico wrote: > Incidentally, you're allowed to put the comma on the last item too: > >  lists = [ >   ['pig', 'horse', 'moose'], >   ['62327', '49123', '79115'], > ] > > Often makes for easier maintenance, especially when you append > array/list elements. > > Chris Ang

Re: Using nested lists and tables

2010-10-28 Thread Iain King
On Oct 28, 2:35 pm, Iain King wrote: ... > (a) I don't know if the order of resolution is predicated left-to- > right in the language spec of if it's an implementation detail > (b) columns[-1].startswith('s') would be better > ... Ignore (b), I didn't read

Re: Using nested lists and tables

2010-10-28 Thread Iain King
On Oct 28, 2:19 pm, Zeynel wrote: > On Oct 28, 4:49 am, Peter Otten <__pete...@web.de> wrote: > > Thank you this is great; but I don't know how to modify this code so > that when the user types the string 's' on the form in the app he sees > what he is typing. So, this will be in GAE. But I have a

relative imports and sub-module execution

2010-09-27 Thread King
Hi, After reading couple of docs and articles, I have implemented a simple test package with nested modules. When running "main.py", everything is working fine. Some of my sub- modules has some small test routines for debug purpose. It's because I am using relative package imports at the top, I am

Re: WMI in Python

2010-09-16 Thread KING LABS
On Sep 16, 12:39 pm, alex23 wrote: > Lawrence D'Oliveiro wrote: > > Why not just call Scriptomatic directly from within the Python script, then? > > Because Scriptomatic _generates scripts to access WMI_, that's what it > _does_. Are you _seriously_ advocating writing Python code to fire up > a W

Re: WMI in Python

2010-09-13 Thread KING LABS
On Sep 14, 10:39 am, KING LABS wrote: > On Sep 13, 8:31 pm, Jerry Hill wrote: > > > On Mon, Sep 13, 2010 at 8:45 AM, KING LABS wrote: > > > Hi All, > > > > I am new to programming and python, Being a system administrator I > > > have chose Inventory

Re: WMI in Python

2010-09-13 Thread KING LABS
On Sep 13, 8:31 pm, Jerry Hill wrote: > On Mon, Sep 13, 2010 at 8:45 AM, KING LABS wrote: > > Hi All, > > > I am new to programming and python, Being a system administrator I > > have chose Inventory (Software & Hardware ) as my first project. > > You'll

Re: WMI in Python

2010-09-13 Thread KING LABS
o your RDBMS you could easily parse these logs using python and the > native db access module. > > I hope this give you a pointer. > > Sent from my iPhone 4. > > On Sep 13, 2010, at 8:45 AM, KING LABS wrote: > > > > > Hi All, > > > I am new to progra

WMI in Python

2010-09-13 Thread KING LABS
Hi All, I am new to programming and python, Being a system administrator I have chose Inventory (Software & Hardware ) as my first project. I would like to know experts advice on the best way to build the same using python. I would like to this tool to evolve into full fledge application. I woul

Re: python interview quuestions

2010-08-10 Thread J Kenneth King
James Mills writes: > On Sat, Aug 7, 2010 at 4:32 AM, Tim Chase > wrote: >>> I would like to aquint myself with Python Interview questions >> >> This came up a while ago: >> >> http://www.mail-archive.com/python-list@python.org/msg168961.html >> >> Most of that thread is still relevant (perhaps

Undo-Redo, copy instance, custom events and a problem

2010-07-25 Thread King
Hi, I am developing an app using wxPython. The Undo-Redo implementation is based on storing pre & post state of an attribute. You store the instance before changing the value and store the instance after changing the values. While undoing or redoing, you copy/replace the current state with stored o

Re: Compile python executable only for package deployment on Linux

2010-07-20 Thread King
Hi Stefan, Well, the idea is similar to package tools like pyinstaller or cx_freeze. There approach is slightly different then what I intend to do here. You have to pass the name of the script to python executable("python main.py") in order to execute it. What I mean here is to create python exec

Compile python executable only for package deployment on Linux

2010-07-20 Thread King
Hi, I have created a simple tool(python script) that creates a self sufficient package ready for deployment. Current implementation is based on shell scripting to set environment for the app and finally execute "python main.py". I am planning to convert "main.py" into an executable. The plan is t

Node based architecture

2010-07-12 Thread King
Hi, I am planning to build a generic node based framework using python. I would start with a simple image editing application. I hope that experienced users understands what am I trying to say here. In simple words: LoaderNode : Load Image from disk OperatorNode : Performs a specific task on data

Re: zipimport (.pyd & .so) files.

2010-07-10 Thread King
I think I am trying to open a can of worms. It's better to leave the idea for now. Prashant -- http://mail.python.org/mailman/listinfo/python-list

zipimport (.pyd & .so) files.

2010-07-09 Thread King
Hi, The 'zipimport' modules can only import (.py & .pyc) files from a zip file and doesn't support importing .pyd & .so files. Recently I was examining the code of Py2Exe (python package deployment tool) and I have found that it is using a module 'zipextimporter' that can import dlls(.pyd) modules

Re: simple python deployment tool

2010-07-08 Thread King
On Jul 8, 2:21 pm, Alexander Kapps wrote: > King wrote: > > Hi, > > > I am writing a python package deployment tool for linux based > > platforms. I have tried various existing > > tool sets but none of them is up to the mark and they have their own > > issu

simple python deployment tool

2010-07-08 Thread King
Hi, I am writing a python package deployment tool for linux based platforms. I have tried various existing tool sets but none of them is up to the mark and they have their own issues. Initially I'll start with simple approach. 1. Find all the modules/packages and copy to "lib" directory. 2. Find

executable builder

2010-07-01 Thread King
Hi, I am trying to build python a cross platform python executable builder to deploy python app. I tried various tools such as py2exe, pyinstaller, cx_freeze but some how they are not upto the mark except py2exe. Unfortunately py2exe is working only on windows based systems. The task is divide in

Re: List of lists surprising behaviour

2010-06-17 Thread J Kenneth King
candide writes: > Let's the following code : > t=[[0]*2]*3 t > [[0, 0], [0, 0], [0, 0]] t[0][0]=1 t > [[1, 0], [1, 0], [1, 0]] > > Rather surprising, isn't it ? Not at all, actually. I'd be surprised if the multiplication operator was aware of object constructors. Even arr

Re: GUIs - A Modest Proposal

2010-06-08 Thread David King
> My concern is simple: I think that Python is doomed to remain a minor > language unless we crack this problem. But making *another* "one true GUI library" just fragments it further. Nobody designs a GUI library intending it to suck. -- http://mail.python.org/mailman/listinfo/python-list

Re: replacing words in HTML file

2010-04-29 Thread Iain King
On Apr 29, 10:38 am, Daniel Fetchinson wrote: > > | > Any idea how I can replace words in a html file? Meaning only the > > | > content will get replace while the html tags, javascript, & css are > > | > remain untouch. > > | > > | I'm not sure what you tried and what you haven't but as a first tr

Re: Python compiled modules are too big in size (even after strip)

2010-04-27 Thread King
Hi Jon, I do have a limited skill sets in c/c++ and also new on linux. I think I am missing some flags or anything when I am compiling python from sources. Still hoping that some one point me out the missing link. Cheers Prashant -- http://mail.python.org/mailman/listinfo/python-list

Python compiled modules are too big in size (even after strip)

2010-04-27 Thread King
Hi, I have just compiled python 2.6.5 from sources on ubuntu "hardy" 8.04. I have used a simple script to do everything in one go: ./configure --enable-shared make make install Python is compiled and installed successfully. However the modules(_socket.so, _random.so etc) are two big in terms of

Re: Code redundancy

2010-04-20 Thread Iain King
On Apr 20, 2:43 pm, Alan Harris-Reid wrote: > Hi, > > During my Python (3.1) programming I often find myself having to repeat > code such as... > > class1.attr1 = 1 > class1.attr2 = 2 > class1.attr3 = 3 > class1.attr4 = 4 > etc. > > Is there any way to achieve the same result without having to rep

Re: Usable street address parser in Python?

2010-04-20 Thread Iain King
On Apr 20, 8:24 am, John Yeung wrote: > My response is similar to John Roth's.  It's mainly just sympathy. ;) > > I deal with addresses a lot, and I know that a really good parser is > both rare/expensive to find and difficult to write yourself.  We have > commercial, USPS-certified products where

Re: Can someone please make it more pythonic or better?

2010-04-19 Thread J Kenneth King
Oltmans writes: > Greetings Python superstars, > > I've a directory structure like following > > tests / > __init__.py > testfile.py > > testfile.py contains following code > > import unittest > > class Calculator(unittest.TestCase): > def test_add(self): > print 'just add

Re: why (1, 2, 3) > [1, 2, 3] is true?

2010-02-25 Thread Iain King
On Feb 25, 2:03 pm, fat bold cyclop wrote: > > Both are not equal, so the comparison returns an arbitrary result in Py2. > > Thanks, Stefan. If I understand you correctly the comparison is not > valid. > But I wonder if there is any logic behind this (in 2.x). > Is it possible to predict result of

Re: Overcoming python performance penalty for multicore CPU

2010-02-08 Thread J Kenneth King
Paul Rubin writes: > Stefan Behnel writes: >> Well, if multi-core performance is so important here, then there's a pretty >> simple thing the OP can do: switch to lxml. >> >> http://blog.ianbicking.org/2008/03/30/python-html-parser-performance/ > > Well, lxml is uses libxml2, a fast XML parser w

Re: Ad hoc lists vs ad hoc tuples

2010-01-27 Thread Iain King
On Jan 27, 10:20 am, Floris Bruynooghe wrote: > One thing I ofter wonder is which is better when you just need a > throwaway sequence: a list or a tuple?  E.g.: > > if foo in ['some', 'random', 'strings']: >     ... > if [bool1, bool2, boo3].count(True) != 1: >    ... > > (The last one only works

Re: substitution

2010-01-21 Thread Iain King
On Jan 21, 2:18 pm, Wilbert Berendsen wrote: > Op maandag 18 januari 2010 schreef Adi: > > > keys = [(len(key), key) for key in mapping.keys()] > > keys.sort(reverse=True) > > keys = [key for (_, key) in keys] > > > pattern = "(%s)" % "|".join(keys) > > repl = lambda x : mapping[x.group(1)] > > s

Re: Symbols as parameters?

2010-01-21 Thread Iain King
On Jan 21, 7:43 am, Martin Drautzburg wrote: > Hello all, > > When passing parameters to a function, you sometimes need a paramter > which can only assume certain values, e.g. > >         def move (direction): >                 ... > If direction can only be "up", "down", "left" or "right", you ca

Re: substitution

2010-01-18 Thread Iain King
On Jan 18, 4:26 pm, Steven D'Aprano wrote: > On Mon, 18 Jan 2010 06:23:44 -0800, Iain King wrote: > > On Jan 18, 2:17 pm, Adi Eyal wrote: > [...] > >> Using regular expressions the answer is short (and sweet) > > >> mapping = { > >>  

Re: substitution

2010-01-18 Thread Iain King
On Jan 18, 2:17 pm, Adi Eyal wrote: > > From: superpollo > > To: > > Date: Mon, 18 Jan 2010 11:15:37 +0100 > > Subject: substitution > > hi. > > > what is the most pythonic way to substitute substrings? > > > eg: i want to apply: > > > foo --> bar > > baz --> quux > > quuux --> foo > > > so that:

Re: substitution

2010-01-18 Thread Iain King
On Jan 18, 12:41 pm, Iain King wrote: > On Jan 18, 10:21 am, superpollo wrote: > > > > > superpollo ha scritto: > > > > hi. > > > > what is the most pythonic way to substitute substrings? > > > > eg: i want to apply: > > > >

Re: substitution

2010-01-18 Thread Iain King
On Jan 18, 10:21 am, superpollo wrote: > superpollo ha scritto: > > > hi. > > > what is the most pythonic way to substitute substrings? > > > eg: i want to apply: > > > foo --> bar > > baz --> quux > > quuux --> foo > > > so that: > > > fooxxxbazyyyquuux --> barxxxquuxyyyfoo > > > bye > > i explai

Re: Writing a string.ishex function

2010-01-14 Thread Iain King
On Jan 14, 3:52 pm, chandra wrote: > Folks, > > I am new to Python and could not find a function along the lines of > string.ishex in Python. There is however, a string.hexdigits constant > in the string module. I thought I would enhance the existing modlue > but am unsure how I should go about it

Re: Different number of matches from re.findall and re.split

2010-01-11 Thread Iain King
On Jan 11, 3:35 pm, Jeremy wrote: > Hello all, > > I am using re.split to separate some text into logical structures. > The trouble is that re.split doesn't find everything while re.findall > does; i.e.: > > > > > found = re.findall('^ 1', line, re.MULTILINE) > > len(found) >    6439 > > tables =

Re: Object Relational Mappers are evil (a meditation)

2009-12-29 Thread J Kenneth King
Steven D'Aprano writes: > On Wed, 23 Dec 2009 10:55:19 -0500, J Kenneth King wrote: > >> Steven D'Aprano writes: >> >>> On Mon, 21 Dec 2009 11:44:29 -0500, J Kenneth King wrote: >>> >>>> A programmer that >>>> lacks cri

Re: Object Relational Mappers are evil (a meditation)

2009-12-23 Thread J Kenneth King
Steven D'Aprano writes: > On Mon, 21 Dec 2009 11:44:29 -0500, J Kenneth King wrote: > >> A programmer that >> lacks critical thinking is a bad programmer. The language they use has >> no bearing on such human facilities. > > That's nonsense, and I can

Re: Object Relational Mappers are evil (a meditation)

2009-12-21 Thread J Kenneth King
Lie Ryan writes: > On 12/17/2009 3:17 PM, J Kenneth King wrote: >> A language is a thing. It may have syntax and semantics that bias it >> towards the conventions and philosophies of its designers. But in the >> end, a language by itself would have a hard time convincin

Re: Object Relational Mappers are evil (a meditation)

2009-12-16 Thread J Kenneth King
Neil Cerutti writes: > On 2009-12-16, J Kenneth King wrote: >> The language doesn't encourage anything. It's just a medium >> like oil paints and canvas. A painting can be good or bad >> despite the medium it is constructed on. The skill of the >> pai

Re: Object Relational Mappers are evil (a meditation)

2009-12-16 Thread J Kenneth King
r0g writes: > J Kenneth King wrote: >> Steven D'Aprano writes: >> >>> On Fri, 11 Dec 2009 19:20:21 -0500, Steve Holden wrote: >>> > > >>>> Hear, hear! >>> That's all very well, but some languages and techniques encourage th

Re: Object Relational Mappers are evil (a meditation)

2009-12-16 Thread J Kenneth King
Steven D'Aprano writes: > On Fri, 11 Dec 2009 19:20:21 -0500, Steve Holden wrote: > >> Simon Forman wrote: >> [...] >>> As far as the OP rant goes, my $0.02: bad programmers will write bad >>> code in any language, with any tool or system or environment they're >>> given. If you want to avoid b

Re: Perl to Python conversion

2009-12-10 Thread J Kenneth King
martin.sch...@gmail.com (Martin Schöön) writes: > First off: I am new here and this is my first post after > lurking for quite some time. Hi. > Second off: I don't know much Python---yet. It's not a very big language. If you have experience programming in other languages, you can probably pick

Re: Question about 'remote objects'

2009-12-09 Thread J Kenneth King
"Frank Millman" writes: > Hi all > > I am writing a multi-user business/accounting application. It is getting > rather complex and I am looking at how to, not exactly simplify it, but find > a way to manage the complexity. > > I have realised that it is logically made up of a number of services

Re: How decoupled are the Python frameworks?

2009-12-07 Thread J Kenneth King
shocks writes: > Hi > > I'm getting back into Python after a long break. I've been developing > large enterprise apps solely with Adobe Flex (ActionScript) for the > past couple years. During that time I've used a number of 'MVC' > frameworks to glue the bits together - among them Cairngorm, a

Re: Go versus Brand X

2009-11-30 Thread J Kenneth King
a...@pythoncraft.com (Aahz) writes: > Comparing Go to another computer language -- do you recognize it? > > http://www.cowlark.com/2009-11-15-go/ If you skip to the conclusion, you'll be better off. The author has an interesting point. Go (the language) is not really ground-breaking. I don't u

Re: Python Programming Challenges for beginners?

2009-11-27 Thread J Kenneth King
astral orange <457r0...@gmail.com> writes: > Hi- > > I am reading the online tutorial along with a book I bought on Python. > I would like to test out what I know so far by solving programming > challenges. Similar to what O'Reilly Learning Perl has. I really > enjoyed the challenges at the end of

Re: Perl conversion to python...

2009-11-23 Thread J Kenneth King
Benjamin Schollnick writes: > Folks, > > I'm having some issues here with pyserial & trying to translate a perl > script to python... It's probably my inexperience with PySerial & > perl that is troubling me... > > Can anyone assist? > > I'm concerned, since I can't seem to receive the data in a

Re: Python/HTML integration: phileas v0.3 released

2009-11-23 Thread J Kenneth King
papa hippo writes: > On 20 nov, 09:02, Stefan Behnel wrote: >> papa hippo, 19.11.2009 19:53: >> >> > The prime goal of 'phileas' is to enable html code to be seamlessly >> > included in python code in a natural looking syntax, without resorting >> > to templatng language. >> >> I assume you know

No duplicate variable

2009-11-20 Thread King
class A(object): def __init__(self, value=0.): self.value = value class B(A): def __init__(self, value=None): A.__init__(self) self.value = value obj = B() When "B" initializes, it overwrite "value" variable of "A". How do I make sure that no variable should not b

Re: python simply not scaleable enough for google?

2009-11-17 Thread J Kenneth King
David Cournapeau writes: > On Tue, Nov 17, 2009 at 10:48 PM, Aaron Watters > wrote: >> >>> I don't think Python and Go address the same set of programmer >>> desires.  For example, Go has a static type system.  Some programmers >>> find static type systems to be useless or undesirable.  Others

Re: Get attribute this way

2009-11-16 Thread King
"eval" can solve this problem right away but I am concerned about security issues. If not "eval" could you suggest something more efficient way. It won't be a big deal to change the format as application is still at development stage? Thanks Prashant Python 2.6.2 Win XP 32 -- http://mail.python.

Re: Get attribute this way

2009-11-16 Thread King
Writing/Reading data to xml is not a problem. The problem is when I have to write to attributes in xml, where a connections has been established. XML: While reading back I have to convert both source and destination strings into object so that I can call connections function using source and targ

Get attribute this way

2009-11-16 Thread King
Python's getattr, setattr and __getattribute__ commands works fine with python types. For example: print o.__getattribute__("name") print getattr(o, "name") This is the easiest way to get an attribute using a string. In my case the "Node" class load/creates all the attributes from a xml file. Exam

Re: object serialization as python scripts

2009-11-16 Thread J Kenneth King
King writes: >> Why is it easier than the above mentioned - they are *there* (except the >> custom xml), and just can be used. What don't they do you want to do? >> >> Other than that, and even security issues put aside, I don't see much >> difference be

Re: object serialization as python scripts

2009-11-13 Thread King
> Why is it easier than the above mentioned - they are *there* (except the > custom xml), and just can be used. What don't they do you want to do? > > Other than that, and even security issues put aside, I don't see much > difference between pickle and python code, except the latter being more > ve

object serialization as python scripts

2009-11-13 Thread King
I have looked upon various object serialization de-serialization techniques. (shelve, pickle, anydbm, custom xml format etc.) What I personally feel that instead of all these methods for saving the objects it would be easier to save the data as python scripts itself. In this case, loading the data

object indexing and item assignment

2009-11-13 Thread King
class MyFloat(object): def __init__(self, value=0.): self.value = value def set(self, value): self.value = value def get(self): return self.value class MyColor(object): def __init__(self, value=(0,0,0)): self.value = (MyFloat(value[0]),

Re: python simply not scaleable enough for google?

2009-11-12 Thread J Kenneth King
mcherm writes: > On Nov 11, 7:38 pm, Vincent Manis wrote: >> 1. The statement `Python is slow' doesn't make any sense to me. >> Python is a programming language; it is implementations that have >> speed or lack thereof. >[...] >> 2. A skilled programmer could build an implementation that com

Re: substituting list comprehensions for map()

2009-11-04 Thread J Kenneth King
Steven D'Aprano writes: > On Tue, 03 Nov 2009 10:22:28 -0500, J Kenneth King wrote: > >> However in this case the procedure by which we derive the value is not >> important or even interesting. It is much more succinct to think of the >> operation as a value and exp

Re: substituting list comprehensions for map()

2009-11-03 Thread J Kenneth King
Ben Finney writes: > J Kenneth King writes: > >> Steven D'Aprano writes: >> >> > from operator import add >> > map(add, operandlist1, operandlist2) >> >> This is the best solution so far. > > Strange to say it's a solution, wh

conditional __init__

2009-11-02 Thread King
class A(object): def __init__(self): pass def printme(self): print "I am A" class B(object): def __init__(self): pass def printme(self): print "I am B" class K(A, B): def __init__(self, value=0): if value == 0: A.__init__(sel

Re: substituting list comprehensions for map()

2009-11-02 Thread J Kenneth King
Steven D'Aprano writes: > On Sun, 01 Nov 2009 23:54:16 -0800, Jon P. wrote: > >> I'd like to do: >> >> resultlist = operandlist1 + operandlist2 >> >> where for example >> >> operandlist1=[1,2,3,4,5] >> operandlist2=[5,4,3,2,1] >> >> and resultlist will become [6,6,6,6,6]. Using map(), I can

Re: Python + twisted = Raindrop (in part)

2009-10-28 Thread J Kenneth King
Terry Reedy writes: > Rrom: > First look: inside Mozilla's Raindrop messaging platform > > http://arstechnica.com/open-source/news/2009/10/first-look-inside-mozillas-raindrop-messaging-platform.ars > > "The backend components that are responsible for retrieving and > processing messages are coded

Re: What IDE has good git and python support?

2009-10-28 Thread J Kenneth King
Aweks writes: > what do you use? emacs. -- http://mail.python.org/mailman/listinfo/python-list

Re: Object Relational Mappers are evil (a meditation)

2009-10-22 Thread J Kenneth King
Aaron Watters writes: > On Oct 16, 10:35 am, mario ruggier wrote: >> On Oct 5, 4:25 pm, Aaron Watters wrote: >> >> > Occasionally I fantasize about making a non-trivial change >> > to one of these programs, but I strongly resist going further >> > than that because the ORM meatgrinder makes it

Re: The rap against "while True:" loops

2009-10-20 Thread Iain King
On Oct 19, 7:51 am, Hendrik van Rooyen wrote: > On Sunday, 18 October 2009 11:31:19 Paul Rubin wrote: > > > Hendrik van Rooyen writes: > > > Standard Python idiom: > > > > if key in d: > > >   d[key] += value > > > else: > > >   d[key] = value > > > The issue is that uses two lookups.  If that's

Re: Simple if-else question

2009-09-30 Thread Iain King
On Sep 30, 7:12 am, Steven D'Aprano wrote: > On Tue, 29 Sep 2009 22:29:10 -0700, John Yeung wrote: > > On Sep 29, 1:15 pm, Carl Banks wrote: > >> Hmm, I wonder if Python should emit a warning if an else is used on a > >> for block with no break inside.  I don't think the else can be invoked > >>

Re: nested structure with "internal references"

2009-09-28 Thread J Kenneth King
Hendrik van Rooyen writes: > On Friday, 25 September 2009 19:11:06 Torsten Mohr wrote: > >> I'd like to use a nested structure in memory that consists >> of dict()s and list()s, list entries can be dict()s, other list()s, >> dict entries can be list()s or other dict()s. >> >> The lists and dicts

Re: easy question, how to double a variable

2009-09-24 Thread Iain King
On Sep 23, 7:36 pm, David C Ullrich wrote: > On Tue, 22 Sep 2009 02:34:53 +, Steven D'Aprano wrote: > > On Mon, 21 Sep 2009 13:50:23 -0500, David C Ullrich wrote: > > >> But you actually want to return twice the value. I don't see how to do > >> that. > > > What? > > > Seriously? > > You're sa

Re: SQLite or files?

2009-09-17 Thread J Kenneth King
ici writes: > I like shelve for saving small amounts of data, user preferences, > recent files etc. > http://docs.python.org/library/shelve.html I like it too, but I hear the great powers that be are going to deprecate it. > > For Qt use QtCore.QCoreApplication.setOrganizationName, > QtCore.QCo

Re: Sanitising arguments to shell commands

2009-08-21 Thread Rick King
shlex doesn't handle unicode input though, so, in general, it's not a good solution. Rick King Southfield MI http://docs.python.org/library/shlex.html module shlex — Simple lexical analysis New in version 1.5.2. "The shlex class makes it easy to write lexical analyzers for

Re: how to use "exec" stmt to get input from user

2009-08-10 Thread Rick King
t how "ShowModal" is spelled in wx right now) with a text box and an Execute button and a Cancel button - if the user hits the Execute button I'd attempt to execute what he'd typed in the box. There are reasons you want to be very careful about this... On Mon, 10 Aug 2009 13:44:17

how to use "exec" stmt to get input from user

2009-08-10 Thread Rick King
so means I have to have a command window. If I add this: self.stdin = self.edt_console_input (where self.edt_console_input is a wxPython text control) it just gets an EOF right away. Is there any way to do what I want to do? This might be better posted on the wxpython list. Thanks fo

py2exe-created exe results in "application failed to initialize"

2009-08-07 Thread Rick King
uot;filetoolGUI.py", other_resources = [(RT_MANIFEST, 1, manifest_template % dict(prog="FileTool"))], dest_base = "FileTool") setup( options = {"py2exe": {"compressed": 1,"optimize": 2,"ascii": 1,"bundle_files": 1}}, zipfile = None, windows = [FileTool], ) Any help will be greatly appreciated! Rick King Southfield MI USA -- http://mail.python.org/mailman/listinfo/python-list

Re: remove last 76 letters from string

2009-08-06 Thread Iain King
On Aug 6, 11:34 am, MRAB wrote: > Iain King wrote: > >>      print >>nucleotides, seq[-76] > > >>      last_part = line.rstrip()[-76 : ] > > > You all mean:   seq[:-76]   , right? (assuming you've already stripped > > any junk off the end o

Re: remove last 76 letters from string

2009-08-06 Thread Iain King
> print >>nucleotides, seq[-76] >      last_part = line.rstrip()[-76 : ] You all mean: seq[:-76] , right? (assuming you've already stripped any junk off the end of the string) Iain -- http://mail.python.org/mailman/listinfo/python-list

Re: Confessions of a Python fanboy

2009-07-31 Thread Iain King
On Jul 31, 4:08 pm, Ethan Furman wrote: > Steven D'Aprano wrote: > > On Thu, 30 Jul 2009 18:47:04 +0100, Tim Rowe wrote: > > >>That and the fact that I couldn't stop laughing for long enough to learn > >>any more when I read in the Pragmatic Programmer's Guide that "Ruby, > >>unlike less flexible

Re: Confessions of a Python fanboy

2009-07-31 Thread Iain King
On Jul 31, 8:28 am, Steven D'Aprano wrote: > On Thu, 30 Jul 2009 18:06:31 -0500, Robert Kern wrote: > > On 2009-07-30 16:44, r wrote: > >> On Jul 30, 4:29 pm, Emmanuel Surleau wrote: > 1.) No need to use "()" to call a function with no arguments. Python > -->  "obj.m2().m3()" --ugly > >>

Re: escaping characters in filenames

2009-07-29 Thread J Kenneth King
Nobody writes: > On Wed, 29 Jul 2009 09:29:55 -0400, J Kenneth King wrote: > >> I wrote a script to process some files using another program. One thing >> I noticed was that both os.listdir() and os.path.walk() will return >> unescaped file names (ie: "My File Wi

escaping characters in filenames

2009-07-29 Thread J Kenneth King
I wrote a script to process some files using another program. One thing I noticed was that both os.listdir() and os.path.walk() will return unescaped file names (ie: "My File With Spaces & Stuff" instead of "My\ File\ With\ Spaces\ \&\ Stuff"). I haven't had much success finding a module or reci

Re: Script runs manually, but cron fails

2009-07-27 Thread J Kenneth King
Bryan writes: > I have a backup script that runs fine when I run it manually from the > command line. When I run it with cron, the script stops running at > random points in the source code. > > The script calls rsync with the subprocess module, which in turn uses > ssh to backup files from a bo

Re: uniicode and executing a process with subprocess.call, or os.system

2009-07-19 Thread Rick King
Thanks. I looked around for alternatives but didn't find this one. Rick Chris Rebert wrote: On Sat, Jul 18, 2009 at 3:30 PM, Rick King wrote: Hello, I want to copy files using subprocess.call or os.system where the file names are non-ascii, e.g. Serbian(latin), c's and s's w

  1   2   3   4   5   >