Re:Leap year

2014-09-27 Thread Dave Angel
Seymore4Head Wrote in message: > Still practicing. Since this is listed as a Pseudocode, I assume this > is a good way to explain something. That means I can also assume my > logic is fading with age. > http://en.wikipedia.org/wiki/Leap_year#Algorithm > > > I didn't have any problem when I di

Re:Keepin constants, configuration values, etc. in Python - dedicated module or what?

2014-09-30 Thread Dave Angel
c...@isbd.net Wrote in message: > I am developing some code which runs on a (remote from me most of the > time) Beaglebone Black single board computer. It reads various items > of data (voltages, currents, temperatures, etc.) using both a 1-wire > bus system and the Beaglebone's ADC inputs. The v

Re: Keepin constants, configuration values, etc. in Python - dedicated module or what?

2014-10-02 Thread Dave Angel
On 09/30/2014 10:55 AM, c...@isbd.net wrote: Dave Angel wrote: >> name. And presumably you never remove an old name from the config. The only things really likely to change (and may change regularly) are the conversion factors, drifting voltage references etc. will inev

Re:Python Basics

2014-10-03 Thread Dave Angel
diarmuid.higg...@mycit.ie Wrote in message: > Hi > > I have just started an introductory course on Python. I have never even seen > a programming language before so I am struggling a bit. Our lecturer has > given us a number of excercises to complete and I am stuck on the one I have > listed be

Re:re search through a text Vs line

2014-10-05 Thread Dave Angel
Shiva Wrote in message: > Hi, > > I am doing a regular expression search for a year through a file. > I think you are being confused in part by your choice of names. Let's go through and describe the variable contents. > fileextract = open(fullfilename,'r') > line = fileextract.read() 'l

Re: re search through a text Vs line

2014-10-05 Thread Dave Angel
Shiva Wrote in message: > OK, > Hi Dave, > > I modified it as below and it works(If there is a way to make this more > efficient please let me know) > Deends on what you mean by efficiency. The big memory efficiency gain was when you got rid of either the read or readlines. Performance

Re:Representing mathematical equations

2014-10-06 Thread Dave Angel
varun...@gmail.com Wrote in message: > Hello, > > I am working on a mathematical equation which I'm finding really hard to > express in python. Could any of you spare some time to help me out? > > The equation looks like this > > b(i,x) = [Σ(l∈L) [bd(l) * dist(l) * hc(l)]] / Σ(l∈L) l > > I ha

Re: Representing mathematical equations

2014-10-06 Thread Dave Angel
varun...@gmail.com Wrote in message: > On Monday, 6 October 2014 15:03:44 UTC+2, varu...@gmail.com wrote: > (Deleted all the 8-space quoting. Either use a better email client or remove the extra 7 lines between every line you quote.) >> >> Okay, I forgot to explain them. L is a set of links,

Re:Toggle

2014-10-08 Thread Dave Angel
Seymore4Head Wrote in message: > I want to toggle between color="Red" and color="Blue" > Here is one: > if color == "Red": > color = "Blue" > else: > color = "Red" > Here is two: > if x = "True" color = "Red" > else: > color="Blue" > x= not x > > Others? > One looks like

Re: TypeError: 'kwarg' is an invalid keyword argument for this function

2014-10-13 Thread Dave Angel
Ian Kelly Wrote in message: > On Sun, Oct 12, 2014 at 6:55 AM, roro codeath wrote: >> How to implement it in my class? >> >> class Str(str): >> def __init__(self, *args, **kwargs): >> pass >> >> Str('smth', kwarg='a') > > The error is coming from the __new__ method. Because str is an

Re:Code Review for Paper, Rock, Scissors

2014-10-14 Thread Dave Angel
Revenant Wrote in message: > > > One thing I want to try to add is a "Press any key to continue" function that > occurs at the end of the program when the user decides to quit. I looked at > some options online, but haven't quite figured it out yet. > Use the curses function getch, as

Re: How to install and run a script?

2014-10-14 Thread Dave Angel
Michael Torrie Wrote in message: > On 10/12/2014 08:05 PM, ryguy7272 wrote: >> Ah!!! I didn't know I needed to run it from the command prompt! Ok, >> not it makes sense, and everything works. >> >> Thanks to all! > > You don't have to run python apps from the command line. Apps that > th

Re:Parsing Python dictionary with multiple objects

2014-10-14 Thread Dave Angel
anuragpatiband...@gmail.com Wrote in message: > I have a dictionary that looks like this: > {"1":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, > "2":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, > "3":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, > "4":{"Key1":"Value1", "Key

Re:downloading from links within a webpage

2014-10-14 Thread Dave Angel
Shiva Wrote in message: > Hi, > > Here is a small code that I wrote that downloads images from a webpage url > specified (you can limit to how many downloads you want). However, I am > looking at adding functionality and searching external links from this page > and downloading the same number of

Re:Parsing Python dictionary with multiple objects

2014-10-14 Thread Dave Angel
anuragpatiband...@gmail.com Wrote in message: > I have a dictionary that looks like this: > {"1":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, > "2":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, > "3":{"Key1":"Value1", "Key2":"Value2", "Key3":"Value3"}, > "4":{"Key1":"Value1", "Key

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Dave Angel
Anurag Patibandla Wrote in message: > Thanks for the response. > Here is the code that I have tried. > > from operator import itemgetter > keys = json.keys() > order = list(keys) > q1 = int(round(len(keys)*0.2)) > q2 = int(round(len(keys)*0.3)) > q3 = int(round(len(keys)*0.5)) > b = [q1,q2,q3] >

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Dave Angel
Anurag Patibandla Wrote in message: > On Wednesday, October 15, 2014 1:10:41 PM UTC-4, Rustom Mody wrote: >> On Wednesday, October 15, 2014 10:30:49 PM UTC+5:30, Anurag Patibandla wrote: >> >> > keys = json.keys() >> >> > order = list(keys) >> >> > q1 = int(round(len(keys)*0.2)) >> >> > q2 = i

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Dave Angel
Anurag Patibandla Wrote in message: > dicts = dict(lists) > print dicts > print dict[0] > > Print dicts works as expected giving me the combine dictionary values. But > when I say dict[0]. I see the error: > TypeError: 'type' object has no attribute '__getitem__' > Of course. You

Re:[ANN] pdb-clone 1.9 - a fast clone of pdb with the remote debugging and attach features

2014-10-15 Thread Dave Angel
Xavier de Gaye Wrote in message: > pdb-clone 1.9 has been released at Pypi: > https://pypi.python.org/pypi/pdb-clone > > Features: >* Improve significantly pdb performance. With breakpoints, pdb-clone runs > just above the speed of the interpreter while pdb runs at 10 to 100 times the > sp

Re: Parsing Python dictionary with multiple objects

2014-10-15 Thread Dave Angel
Anurag Patibandla Wrote in message: > On Wednesday, October 15, 2014 1:35:43 PM UTC-4, Rustom Mody wrote: >> On Wednesday, October 15, 2014 10:51:11 PM UTC+5:30, Anurag Patibandla wrote: >> >> > Here is my sample dict if that helps: >> >> > >> >> > >> >> > >> >> > json = {"1": {"Status": "

Re: Processing a file using multithreads

2011-09-08 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Abhishek Pratap wrote: Hi Guys My experience with python is 2 days and I am looking for a slick way to use multi-threading to process a file. Here is what I would like to do which is somewhat similar to MapReduce in concept. # test case 1. My input file is 10 GB. 2.

Re: Invoke a superclass method from a subclass constructor

2011-09-11 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Kayode Odeyemi wrote: Hello friends, An instance of my subclass doesn't invoke its superclass method, except when it is referenced directly. Here is what I mean: class A(object): ... def log(self, module): ... return str('logged') ... class B(A):

Re: How do I automate the removal of all non-ascii characters from my code?

2011-09-12 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Steven D'Aprano wrote: On Mon, 12 Sep 2011 06:43 pm Stefan Behnel wrote: I'm not sure what you are trying to say with the above code, but if it's the code that fails for you with the exception you posted, I would guess that the problem is in the "[more stuff here]" pa

Re: Invoke a superclass method from a subclass constructor

2011-09-13 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Kayode Odeyemi wrote: When an instance of a class is created, all codes within that instance block should be executed. That's my understanding of OOP. I don't understand this phrasing at all. Could you show a specific example of something that does not execute code

Re: The Usenet newsgroup news:comp.lang.python ...

2011-09-14 Thread Dave Angel
On 01/-10/-28163 02:59 PM, mano mano wrote: Mikael Lyngvig accurately summarizes comp.lang.python discussion of the technical merits of Tkinter, wxPython, and Python-bound JPI. Malcolm Tredinnick ... http://12..89/ SPAM ALERT -- http://mail.python.org/mailman/listinfo/python-l

Re: os independent rename

2011-09-17 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Nobody wrote: On Sat, 17 Sep 2011 20:28:32 +0430, Lee Harr wrote: So, what is the best way to do this that will behave the same across operating systems? Delete the destination first, but after checking that it isn't the same as the source. On Windows, that last bit

Re: Re: packages, modules and double imports - oh my!

2011-10-03 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Chris Withers wrote: On 03/10/2011 11:22, Chris Rebert wrote: http://docs.python.org/library/runpy.html : "The runpy module['s] main use is to implement the -m command line switch" "If the supplied module name refers to a package rather than a normal module, then tha

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-03 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Aivar Annamaa wrote: Hi! I'm looking for a trick or hidden feature to make Python 3 automatically call a "main" function but without programmers writing `if __name__ == "__main__": ...` I found rejected PEP 299, but i thought that maybe there's something new already.

Re: Is it possible to create C-style "main" function in Python? (for teaching purposes)

2011-10-03 Thread Dave Angel
On 01/-10/-28163 02:59 PM, rantingrick wrote: On Oct 3, 2:14 pm, Dave Angel wrote: Like it or not, there are plenty of globals already there, one of them being __name__ . All the built-ins are effectively global, and so is any function they define at top-level. I keep wondering if that

Re: A tuple in order to pass returned values ?

2011-10-05 Thread Dave Angel
On 01/-10/-28163 02:59 PM, faucheuse wrote: Hi, (new to python and first message here \o/) I was wondering something : when you do : return value1, value2, value3 It returns a tuple. So if I want to pass these value to a function, the function have to look like : def function(self,(value1, valu

Re: Writing file out to another machine

2011-10-06 Thread Dave Angel
On 01/-10/-28163 02:59 PM, Dennis Lee Bieber wrote: On Wed, 05 Oct 2011 21:36:34 -0400, Terry Reedy declaimed the following in gmane.comp.python.general: On 10/5/2011 5:31 PM, Chris Angelico wrote: On Thu, Oct 6, 2011 at 8:22 AM, John Gordon wrote: I assume he intended "S:" to indicate a re

Re: Usefulness of the "not in" operator

2011-10-08 Thread Dave Angel
On 01/-10/-28163 02:59 PM, candide wrote: Le 08/10/2011 12:42, candide a écrit : >>> not ('th' in "python") False >>> After browsing source code, I realize that parenthesis are not necessary ("not" has higher precedence than "in"). You should say "... parenthesis are not necessary

Re: revive a generator

2011-10-21 Thread Dave Angel
On 10/20/2011 10:09 PM, Yingjie Lan wrote: What if the generator is passed in as an argument when you are writing a function? That is, the expression is not available? Secondly, it would be nice to automatically revive it. For example, when another for-statement or other equivalent is appli

Re: What is wrong with my code?

2011-10-23 Thread Dave Angel
On 10/23/2011 06:03 AM, apometron wrote: import os nome = sys.argv[1] final = nome for i in nome: print i if nome[i] = "_": final[i] = " " os.rename(nome, final) What do you want to be wrong with it? There are so many things, it'd be fun to try to see who could come up with the

Re: getroot() problem

2011-10-23 Thread Dave Angel
On 10/23/2011 09:06 PM, wrote: C:\Documents and Settings\peng>cd c:\python32 C:\Python32>python Python 3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win 32 Type "help", "copyright", "credits" or "license" for more information. import lxml.html sfile='ht

Re: What is wrong with my code?

2011-10-24 Thread Dave Angel
(Don't top-post. Put your response after the part you're quoting from earlier messages. And include enough that somebody can help with minimal effort.) On 10/24/2011 12:30 AM, apometron wrote: The problem is that it is not reporting any error. The do something and quits silently. No rename

Re: [Tutor] What is wrong with my code?

2011-10-25 Thread Dave Angel
(Once again, please don't top-post. It makes your responses out of order) On 10/25/2011 04:24 AM, apometron wrote: I did it very much times, Anssi. Beyond of run it on Python 2.7 latest build, what do you suggest? Do install Python 3.2 along the Python 2.7 installation could give me any prob

Re: inserting \ in regular expressions

2011-10-26 Thread Dave Angel
On 10/26/2011 03:48 PM, Ross Boylan wrote: I want to replace every \ and " (the two characters for backslash and double quotes) with a \ and the same character, i.e., \ -> \\ " -> \" I have not been able to figure out how to do that. The documentation for re.sub says "repl can be a string or

Re: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab?

2011-10-31 Thread Dave Angel
On 10/31/2011 03:54 PM, pyt...@bdurham.com wrote: Wondering if there's a fast/efficient built-in way to determine if a string has non-ASCII chars outside the range ASCII 32-127, CR, LF, or Tab? I know I can look at the chars of a string individually and compare them against a set of legal chars

Re: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab?

2011-10-31 Thread Dave Angel
On 10/31/2011 05:47 PM, Dave Angel wrote: On 10/31/2011 03:54 PM, pyt...@bdurham.com wrote: Wondering if there's a fast/efficient built-in way to determine if a string has non-ASCII chars outside the range ASCII 32-127, CR, LF, or Tab? I know I can look at the chars of a string individ

Re: Efficient, built-in way to determine if string has non-ASCII chars outside ASCII 32-127, CRLF, Tab?

2011-10-31 Thread Dave Angel
On 10/31/2011 08:32 PM, Patrick Maupin wrote: On Mon, Oct 31, 2011 at 4:08 PM, Dave Angel wrote: Yes. Actually, you don't even need the split() -- you can pass an optional deletechars parameter to translate(). On Oct 31, 5:52 pm, Ian Kelly wrote: That sounds overly complicated and

Re: proving two formula are same each other!

2011-11-01 Thread Dave Angel
On 11/01/2011 08:03 AM, pyman wrote: hello, I need some idea to prove two formula is same. if N = 3, these formula are same each other. each formula has 3 input . To prove this, drawing shape or anything would be possible. how can I do this? please give me your idea! for example: N = 1 : formula

Re: proving two formula are same each other!

2011-11-01 Thread Dave Angel
(You forgot to do a REPLY-ALL, so that your message didn't get sent to the list) Python doesn't have formulae, it has functions and methods. So you have to describe more completely what kind of formula you have, math, physics, chemistry? the formula is related to math. And how is

Re: Assign values from list to list of instances

2011-11-01 Thread Dave Angel
On 11/01/2011 11:05 AM, Gnarlodious wrote: I want to assign a list of variables: locus=[-2, 21, -10, 2, 12, -11, 0, 3] updating a list of objects each value to its respective instance: for order in range(len(Orders)): Orders[order].locus=locus[order] This works, even though it reads li

Re: understand program used to create file

2011-11-01 Thread Dave Angel
On 11/01/2011 03:27 PM, pacopyc wrote: Hi, I have about 1 files .doc and I want know the program used to create them: writer? word? abiword? else? I'd like develop a script python to do this. Is there a module to do it? Can you help me? Thanks If you're on Linux, just use the process module

Re: fast copying of large files in python

2011-11-02 Thread Dave Angel
On 11/02/2011 03:31 PM, Catherine Moroney wrote: Hello, I'm working on an application that as part of its processing, needs to copy 50 Meg binary files from one NFS mounted disk to another. The simple-minded approach of shutil.copyfile is very slow, and I'm guessing that this is due to the d

Re: Python lesson please

2011-11-06 Thread Dave Angel
On 11/06/2011 01:14 PM, gene heskett wrote: Greetings experts: I just dl'd the duqu driver finder script from a link to NSS on /., and fixed enough of the tabs in it to make it run error-free. At least python isn't having a litter of cows over the indentation now. But it also runs instantly on

Re: Python lesson please

2011-11-06 Thread Dave Angel
On 11/06/2011 06:10 PM, gene heskett wrote: On Sunday, November 06, 2011 06:07:36 PM Dave Angel did opine: On 11/06/2011 01:14 PM, gene heskett wrote: Greetings experts: I just dl'd the duqu driver finder script from a link to NSS on /., and fixed enough of the tabs in it to make i

Re: Python lesson please

2011-11-07 Thread Dave Angel
On 11/07/2011 06:22 AM, gene heskett wrote: On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: Are you talking about this one? https://github.com/halsten/Duqu-detectors/blob/master/DuquDriverPatterns .py Yes. My save as renamed it, still has about 30k of tabs in it. But I pull

Re: read from file with mixed encodings in Python3

2011-11-07 Thread Dave Angel
On 11/07/2011 09:23 AM, Jaroslav Dobrek wrote: Hello, in Python3, I often have this problem: I want to do something with every line of a file. Like Python3, I presuppose that every line is encoded in utf-8. If this isn't the case, I would like Python3 to do something specific (like skipping the

Re: Python lesson please

2011-11-07 Thread Dave Angel
On 11/07/2011 11:40 AM, gene heskett wrote: On Monday, November 07, 2011 11:30:45 AM Dave Angel did opine: Back on the list.. On 11/07/2011 06:22 AM, gene heskett wrote: On Monday, November 07, 2011 05:35:15 AM Peter Otten did opine: Are you talking about this one? https://github.com

Re: Extracting elements over multiple lists?

2011-11-07 Thread Dave Angel
On 11/07/2011 01:01 PM, JoeM wrote: Thanks guys, I was just looking for a one line solution instead of a for loop if possible. Why do you consider [x.remove(x[0]) for x in [a,b,c]] cheating? It seems compact and elegant enough for me. Cheers Are you considering the possibility that two of th

Re: memory management

2011-11-07 Thread Dave Angel
On 11/07/2011 02:43 PM, Juan Declet-Barreto wrote: Hi, Can anyone provide links or basic info on memory management, variable dereferencing, or the like? I have a script that traverses a file structure using os.walk and adds directory names to a list. It works for a small number of directorie

Re: memory management

2011-11-07 Thread Dave Angel
On 11/07/2011 03:33 PM, Juan Declet-Barreto wrote: Well, I am using Python 2.5 (and the IDLE shell) in Windows XP, which ships with ESRI's ArcGIS. In addition, I am using some functions in the arcgisscripting Python geoprocessing module for geographic information systems (GIS) applications, wh

Re: Python ORMs Supporting POPOs and Substituting Layers in Django

2011-11-08 Thread Dave Angel
On 11/08/2011 02:35 AM, Chris Angelico wrote: On Tue, Nov 8, 2011 at 4:09 PM, Lie Ryan wrote: I much prefer the "everything's an object" notion. C's array literals are just as weird (although in C, you can directly dereference a literal character array - "ABCDEFG"[note_idx] will give you a note

Re: Get keys from a dicionary

2011-11-11 Thread Dave Angel
On 11/11/2011 11:33 AM, macm wrote: Hi Sorry ! My mistake. myDict = {} myDict['foo'] = {} myDict['foo']['bar'] = 'works' - def myFunction( MyObj ): ... # MyObj is a nested dicionary (normaly 2 steps like myDict['foo'] ['bar']) No, it's not. It's a string "works". There's no di

Re: Extracting elements over multiple lists?

2011-11-15 Thread Dave Angel
On 11/15/2011 12:01 PM, Prasad, Ramit wrote: (Peter's "del" solution is quite close, but I find the 'del' statement tricky in python and will mislead many python newcomers) Can you expand on why 'del' is "tricky"/misleading? Ramit a = someexpression... b = a del a Does not (necessaril

Re: Multiple threads

2011-11-16 Thread Dave Angel
On 11/16/2011 12:00 PM, Jack Keegan wrote: Hi Chris, On Wed, Nov 16, 2011 at 1:55 PM, Chris Angelico wrote: First off, it's better in CPython (the most popular Python) to use multiple processes than multiple threads. I had been looking into treads and process/subprocess myself a while ago a

Re: Multiple threads

2011-11-16 Thread Dave Angel
On 11/16/2011 12:55 PM, Michael Hunter wrote: On Wed, Nov 16, 2011 at 9:27 AM, Dave Angel wrote: On 11/16/2011 12:00 PM, Jack Keegan wrote: [...] Processes [...] and the OS is generally better at scheduling them than it is at scheduling threads within a single process. If you have multiple

Re: Multiple threads

2011-11-16 Thread Dave Angel
On 11/16/2011 01:22 PM, Dave Angel wrote: (You're top-posting. Put your remarks AFTER what you're quoting) On 11/16/2011 12:52 PM, Jack Keegan wrote: Ok, I thought that processes would do the same job as threads. So would the general rule be some thing like so: If I want anothe

Re: Both Python 2.5.2 and 2.7.2 flop the same way under Win 7

2011-11-17 Thread Dave Angel
On 11/17/2011 03:31 PM, W. eWatson wrote: On 11/17/2011 9:39 AM, John Gordon wrote: Can you add IDLE manually to the associated applications list? Tried that by sending it directly to idle.pyw, but then trying to get there through the Edit with menu caused a "invalid Win32 app." You've bee

Re: Format the ouput in my python code

2011-11-21 Thread Dave Angel
On 11/21/2011 07:13 AM, sl33k wrote: I am printing the numbers from 1 to 100. In that, I want to display multiples of 3,5 and of both as mulof3, mul0f5 and mulof3and5 respectively. I am getting the output I want but I would like to format the output to print only 10 number per line. How do I g

Re: Format the ouput in my python code

2011-11-21 Thread Dave Angel
On 11/21/2011 09:27 AM, Dave Angel wrote: On 11/21/2011 07:13 AM, sl33k wrote: I am printing the numbers from 1 to 100. In that, I want to display multiples of 3,5 and of both as mulof3, mul0f5 and mulof3and5 respectively. I am getting the output I want but I would like to format the output

Re: decorators and closures

2011-11-21 Thread Dave Angel
On 11/21/2011 09:44 AM, Andrea Crotti wrote: With one colleague I discovered that the decorator code is always executed, every time I call a nested function: def dec(fn): print("In decorator") def _dec(): fn() return _dec def nested(): @dec def fun(): print

Re: decorators and closures

2011-11-21 Thread Dave Angel
On 11/21/2011 10:35 AM, Andrea Crotti wrote: On 11/21/2011 03:06 PM, Dave Angel wrote: Your function 'nested' isn't nested, 'fun' is. What you discovered is that a decorator is always executed, every time a nested decorated function is defined. You've also

Re: a qustion about import that really confuses me

2011-11-22 Thread Dave Angel
On 11/22/2011 05:18 AM, David Lu wrote: Hi, there. I have two files: a.py: # -*- coding: utf-8 -*- print('in a') import b print('var') VAR = 1 def p(): print('{}, {}'.format(VAR, id(VAR))) if __name__ == '__main__': VAR = -1 p() b.p() # Where does this VAR come from?

Re: suitability of python

2011-11-24 Thread Dave Angel
On 11/24/2011 07:31 AM, Rudra Banerjee wrote: Dear friends, I am a newbie in python and basically i use python for postprocessing like plotting, data manipulation etc. Based on ease of programming on python I am wondering if I can consider it for the main development as well. My jobs (written on

Re: Does py2app improves speed?

2011-11-24 Thread Dave Angel
On 11/24/2011 08:26 AM, Ricardo Mansilla wrote: Well, that's sad... I think Im gonna end getting back to C++ for This. But anyway, thanks a lot for the quick answer... Bye. Just because Py2app doesn't improve speed doesn't mean there aren't other ways to gain speed, while still using the Pytho

Re: Does py2app improves speed?

2011-11-24 Thread Dave Angel
slow yet. Do you think there is another way to do This? Probably i'm missing something here... On 24/11/2011, at 07:38, Dave Angel wrote: On 11/24/2011 08:26 AM, Ricardo Mansilla wrote: Well, that's sad... I think Im gonna end getting back to C++ for This. But anyway, thanks a l

Re: How to get path to Python standard library directory?

2011-11-25 Thread Dave Angel
On 11/25/2011 06:24 AM, user wrote: In a Makefile (or sometimes inside python) I need the path to the root of the Python standard lib folder used by "env python". e.g. /usr/lib/python2.6/ orC:\Python27\Lib\ what is the best/canonical way to get that? You could look at sys.executable.

Re: Automatic import of submodules

2011-11-25 Thread Dave Angel
On 11/25/2011 08:00 AM, Massi wrote: Hi everyone, in my project I have the following directory structure: plugins | -- wav_plug | -- __init__.py -- WavPlug.py -- mp3_plug | -- __init__.py -- Mp3Plug.py ... --

Re: How to keep Console area fixed for a thread

2011-11-26 Thread Dave Angel
On 11/25/2011 01:00 PM, Nikunj Badjatya wrote: Can anyone throw some light on this please ! ? ( when you top-post, you confuse things. comp.lang.python follows the usual convention of putting new material after the parts you're quoting. Further, trying to embed images inside html messages

Re: my new project, is this the right way?

2011-11-26 Thread Dave Angel
On 11/26/2011 06:41 PM, 8 Dihedral wrote: On Saturday, November 26, 2011 1:01:34 AM UTC+8, rusi wrote: On Nov 14, 3:41 pm, Tracubik wrote: Hi all, i'm developing a new program. Mission: learn a bit of database management Idea: create a simple, 1 window program that show me a db of movies i

Re: my new project, is this the right way?

2011-11-26 Thread Dave Angel
On 11/26/2011 10:14 PM, 8 Dihedral wrote: On Sunday, November 27, 2011 10:49:20 AM UTC+8, Roy Smith wrote: This is a good point. In general, databases differ from in-memory data structures in that they provide: 1) Persistence 2) Data integrity 3) Shared access Shared in access in a loc

Re: Does py2app improves speed?

2011-11-28 Thread Dave Angel
On 11/28/2011 03:03 PM, Alan Meyer wrote: On 11/24/2011 9:27 AM, Dave Angel wrote: ... Several ways to speed up code. 1) use language features to best advantage 2) use 3rd party libraries that do certain things well 3) use best algorithms, subject to #1 and #2 4) have someone else review the

Re: python 2.5 and ast

2011-11-28 Thread Dave Angel
On 11/28/2011 03:08 PM, Terry Reedy wrote: On 11/28/2011 6:45 AM, Andrea Crotti wrote: I'm happily using the ast module to analyze some code, but my scripts need also to run unfortunately on python 2.5 The _ast was there already, but the ast helpers not yet. Is it ok if I just copy over the sou

Re: Using the Python Interpreter as a Reference

2011-11-29 Thread Dave Angel
On 11/29/2011 03:12 AM, Steven D'Aprano wrote: On Tue, 29 Nov 2011 13:57:32 +1100, Chris Angelico wrote: I'm inclined toward an alternative: explicit recursion. Either a different syntax, or a special-case on the use of the function's own name, but whichever syntax you use, it compiles in a "re

Re: Total newbie question: Best practice

2011-11-29 Thread Dave Angel
On 11/29/2011 03:06 PM, Colin Higwell wrote: Hi, I am just starting to learn Python (I have been at it only a few hours), so please bear with me. I have a few very small scripts (do you call them scripts or programs?) which work properly, and produce the results intended. However, they are mono

Re: Complete beginner, any help appreciated :) - For Loops

2011-12-01 Thread Dave Angel
On 12/01/2011 06:32 AM, Pedro Henrique G. Souto wrote: On 01/12/2011 08:53, Mark wrote: Hi there, I'm a complete beginner to Python and, aside from HTML and CSS, to coding in general. I've spent a few hours on it and think I understand most of the syntax. However, I'm wondering a bit about

Re: order independent hash?

2011-12-01 Thread Dave Angel
On 12/01/2011 10:35 AM, 8 Dihedral wrote: On Wednesday, November 30, 2011 8:47:13 PM UTC+8, Peter Otten wrote: Neal Becker wrote: I like to hash a list of words (actually, the command line args of my program) in such a way that different words will create different hash, but not sensitive

Re: order independent hash?

2011-12-02 Thread Dave Angel
On 12/01/2011 08:55 AM, Neal Becker wrote: Gelonida N wrote: On 11/30/2011 01:32 PM, Neal Becker wrote: I like to hash a list of words (actually, the command line args of my program) in such a way that different words will create different hash, but not sensitive to the order of the words. An

Re: struct calcsize discrepency?

2011-12-04 Thread Dave Angel
On 12/04/2011 09:35 AM, Chris Angelico wrote: On Mon, Dec 5, 2011 at 1:25 AM, Glen Rice wrote: In IPython: import struct struct.calcsize('4s') 4 struct.calcsize('Q') 8 struct.calcsize('4sQ') 16 This doesn't make sense to me. Can anyone explain? Same thing happens in CPython, and it loo

Re: class print method...

2011-12-04 Thread Dave Angel
On 12/05/2011 02:11 AM, Suresh Sharma wrote: Hello All, I am new to python and i have stuck up on a particular issue with classes, i understand this might be a very dumb question but please help me out. I have created two classes and whenever i try to print the objects i get this message but not

Re: Fwd: class print method...

2011-12-05 Thread Dave Angel
On 12/05/2011 07:41 AM, Lie Ryan wrote: 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.

Re: sending a variable to an imported module

2011-12-08 Thread Dave Angel
On 12/08/2011 06:28 AM, Bastien Semene wrote: Hi list, I'm trying to pass a variable to an imported module without singletons. I've seen in the doc, and tested that I can't use global to do it : === module.py === def testf(): print test === main.py === global test test = 1 imported_module =

Re: Verbose and flexible args and kwargs syntax

2011-12-12 Thread Dave Angel
On 12/12/2011 12:46 PM, gene heskett wrote: On Monday, December 12, 2011 12:44:27 PM Chris Angelico did opine: This is the basis of the grade-school "casting out nines" method of checking arithmetic. Set c=9 and you can calculate N%c fairly readily (digit sum - I'm assuming here that the arithm

Re: Overriding a global

2011-12-12 Thread Dave Angel
On 12/12/2011 04:28 PM, Steven D'Aprano wrote: On Mon, 12 Dec 2011 12:13:33 +0100, Jean-Michel Pichavant wrote: Using the same name for 2 different objects is a bad idea in general. We have namespaces precisely so you don't need to care about making names globally unique. True, but in this c

Re: Overriding a global

2011-12-12 Thread Dave Angel
On 12/12/2011 06:48 PM, Joshua Landau wrote: If a function knows of the presence of a global, it's not asking too much for it to not re-use the same name in local scope. Yes. It's just a function wanting to act as-if it were in a different environment than its default. By that same reasoning y

Re: What is this widget?

2011-12-14 Thread Dave Angel
On 12/14/2011 01:47 PM, Muddy Coder wrote: Hi Folks, I am trying to write letters on a photo that is opened in a canvas. So I think I must need a widget to contain the letters I will type in. I tried to use a Label, it worked. But, a Label covered part of the photo underneath, so I can't use it.

Re: file data => array(s)

2011-12-14 Thread Dave Angel
On 12/14/2011 05:20 PM, Eric wrote: I'm trying to read some file data into a set of arrays. The file data is just four columns of numbers, like so: 1.22.2 3.3 0.5 0.1 0.21.0 10.1 ... and so on I'd like to read this into four arrays, one array for each column. Alternat

Re: Odd behavior of object equality/identity in the context of relative vs fully qualified imports

2011-12-15 Thread Dave Angel
On 12/15/2011 09:34 AM, Nathan Rice wrote: I just ran into this yesterday, and I am curious if there is a rational behind it... I have a class that uses a dictionary to dispatch from other classes (k) to functions for those classes (v). I recently ran into a bug where the dictionary would repor

Re: calculate difference between two timestamps [newbie]

2011-12-17 Thread Dave Angel
On 12/17/2011 05:19 AM, nukeymusic wrote: I'm trying to calculate the difference in seconds between two timestamps, but I'm totally stuck: date1="Dec-13-09:47:12" date2="Dec-13-09:47:39" diff=datetime.date(date2)-datetime.date(date1) Traceback (most recent call last): File "", line 1, in Typ

Re: the slash & Windows paths

2011-12-19 Thread Dave Angel
On 12/19/2011 05:02 PM, Juan Declet-Barreto wrote: All, I have a Windows-style path that I need to modify so Python functions can find it. For example, the path "C:\Projects\Population_Pyramids\charts\test.xls" is being interpreted as pointing to a file called "est.xls" since the "t" is being

Re: Text Processing

2011-12-20 Thread Dave Angel
On 12/20/2011 02:17 PM, Yigit Turgut wrote: Hi all, I have a text file containing such data ; ABC --- -2.0100e-018.000e-028.000e-05 -2.e-010.000e+00 4.800e-04 -1.9900e-014.000e-02

Re: Why widgets become 'NoneType'?

2011-12-21 Thread Dave Angel
On 12/21/2011 07:59 AM, Muddy Coder wrote: Hi Folks, I was driven nuts by this thing: widgets lost their attributes, then I can't configure them. Please take a look at the codes below: from Tkinter import * canvas = Canvas(width=300, height=400, bg='white') canvas.pack(expand=NO, fill=BOTH) pic

Re: Which libraries for Python 2.5.2

2011-12-27 Thread Dave Angel
On 12/27/2011 10:31 PM, W. eWatson wrote: On 12/27/2011 6:27 PM, Ian Kelly wrote: http://www.dll-files.com/dllindex/dll-files.shtml?msvcp71 (or just find it on another Windows XP PC) and copy it into C:\Windows\System32. Don't forget to run regsvr32 to register it. HTH, Ian You are very likel

Re: Help in rotate 13 program

2011-12-29 Thread Dave Angel
On 12/29/2011 11:25 AM, Sayantan Datta wrote: On Thu, Dec 29, 2011 at 5:34 PM, Chris Angelico wrote: On Thu, Dec 29, 2011 at 10:48 PM, Sayantan Datta wrote: for line in sys.stdin : for char in line : sys.stdout.write(rotate13_letter(char)) cat sample.html | python rot13.py rot13.

Re: Generating sin/square waves sound

2011-12-30 Thread Dave Angel
On 12/30/2011 02:17 AM, Paulo da Silva wrote: Hi, Sorry if this is a FAQ, but I have googled and didn't find any satisfatory answer. Is there a simple way, preferably multiplataform (or linux), of generating sinusoidal/square waves sound in python? Thanks for any answers/suggestions. If you're

Re: Doing a HTTP DELETE operation with urllib2?

2011-12-30 Thread Dave Angel
On 12/30/2011 03:37 PM, Steven D'Aprano wrote: On Fri, 30 Dec 2011 10:57:06 -0800, Roy Smith wrote: Ah, cool. I didn't know you could do that. Thanks. Who are you talking to, and what is "that"? Replies with no context are somewhat less than useful. It might have made sense in your head whe

Re: Can't write to a directory made w/ os.makedirs

2012-01-02 Thread Dave Angel
On 01/01/2012 10:14 PM, David Goldsmith wrote: On Jan 1, 7:05 am, Tim Golden wrote: On 01/01/2012 12:05, David Goldsmith wrote: >> ie can the Python process creating the directories, > > Yes. > >> and a subprocess called from it create a simple file? > > No. > >> Dependin

<    11   12   13   14   15   16   17   18   19   20   >