Re: askstring Window to the top under Windows

2007-03-06 Thread Jussi Salmela
Jussi Salmela kirjoitti: > > > > Every GUI implementation has a command loop and things to initiate the OOPS: an EVENT loop Cheers, Jussi -- http://mail.python.org/mailman/listinfo/python-list

Re: askstring Window to the top under Windows

2007-03-06 Thread Jussi Salmela
iwl kirjoitti: > On 6 Mrz., 14:48, "Tim Golden" <[EMAIL PROTECTED]> wrote: >> On Mar 6, 1:13 pm, "iwl" <[EMAIL PROTECTED]> wrote: >> >> It's not clear whether you're talking about the usual >> "Why do I get a DOS window when I run my python script?" >> question -- to which the answer is, in essence

Re: askstring Window to the top under Windows

2007-03-06 Thread Jussi Salmela
iwl kirjoitti: > Hi, > > I tryed askstring to input some text in my script, > but some ugly empty Window appears with the > Input-Window behind and all together behind my > Console showing my script. So all have to brought > to the top first by the user - very unconfortable > Are you asking abou

Re: Good handling of input data (was Re: Newbie question)

2007-03-06 Thread Jussi Salmela
Tommy Grav kirjoitti: > > Thanks for the great response. > > So how would you handle this type of error handling? > My main problem is that occasionally there is an entry > in the list that is a string: > > 0.9834 134.4933 78.009 run11 27 > > Again I would like to avoid having to individually

Re: Building a dictionary from a tuple of variable length

2007-03-05 Thread Jussi Salmela
[EMAIL PROTECTED] kirjoitti: > Hi, > > I have the following tuple - > > t = ("one","two") > > And I can build a dictionary from it as follows - > > d = dict(zip(t,(False,False))) > > But what if my tuple was - > > t = ("one","two","three") > > then I'd have to use - > > d = dict(zip(t,(Fals

Re: Sorting strings containing special characters (german 'Umlaute')

2007-03-04 Thread Jussi Salmela
Robin Becker kirjoitti: > > Björn, in one of our projects we are sorting in javascript in several > languages English, German, Scandinavian languages, Japanese; from > somewhere (I cannot actually remember) we got this sort spelling > function for scandic languages > > a > .replace(/\u00C4/g,'

Re: Perl and Python, a practical side-by-side example.

2007-03-03 Thread Jussi Salmela
Shawn Milo kirjoitti: > > I am not looking for the smallest number of lines, or anything else > that would make the code more difficult to read in six months. Just > any instances where I'm doing something inefficiently or in a "bad" > way. > > I'm attaching both the Perl and Python versions, an

Re: Lists: Converting Double to Single

2007-03-01 Thread Jussi Salmela
Duncan Booth kirjoitti: > Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > >> For floating point, smallest magnitude to largest IS the most >> precise. >> >> Pretend you only have 2 significant digits of precision... >> >> 10 + 0.4 + 0.4 + 0.4 => 10 >> >> 0.4 + 0.4 + 0.4 + 10 =>

Re: How to Read Bytes from a file

2007-03-01 Thread Jussi Salmela
Bart Ogryczak kirjoitti: > On Mar 1, 7:52 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: >> It seems like this would be easy but I'm drawing a blank. >> >> What I want to do is be able to open any file in binary mode, and read >> in one byte (8 bits) at a time and then count the number of 1 b

Re: quickly read a formated file?

2007-03-01 Thread Jussi Salmela
rzed kirjoitti: > [EMAIL PROTECTED] wrote in > news:[EMAIL PROTECTED]: > >> lialie: >>> The formated file may be very popularly, but the module >>> ConfigPaser doesn't handle it. Is there a way to process it >>> freely? >> First try, assuming the input file can be read whole. The code >> isn't m

Re: How to use cmp() function to compare 2 files?

2007-02-27 Thread Jussi Salmela
[EMAIL PROTECTED] kirjoitti: > On Feb 27, 12:07 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> In <[EMAIL PROTECTED]>, [EMAIL PROTECTED] >> wrote: >> >>> File "./scripts/regressionTest.py", line 30, in getSnapShot >>> if (difflib.context_diff(f1.readlines(), f2.readlines()).len()

Re: Help on object scope?

2007-02-27 Thread Jussi Salmela
[EMAIL PROTECTED] kirjoitti: > > global names seemed to be the best idea. The only problem is now I > have to type common.r.t instead of just r.t. If I put common in the / > lib directory, it is even worse and I have to type lib.common.r.t. I > like that it is explicit and perhaps this is the Pyt

Re: Referencing Items in a List of Tuples

2007-02-25 Thread Jussi Salmela
Paddy kirjoitti: > On Feb 25, 2:01 am, [EMAIL PROTECTED] wrote: >> While working with lists of tuples is probably very common, none of my >> five Python books or a Google search tell me how to refer to specific items >> in each tuple. I find references to sorting a list of tuples, but not >> extr

Re: Possible to set cpython heap size?

2007-02-22 Thread Jussi Salmela
Andy Watson kirjoitti: > I have an application that scans and processes a bunch of text files. > The content I'm pulling out and holding in memory is at least 200MB. > > I'd love to be able to tell the CPython virtual machine that I need a > heap of, say 300MB up front rather than have it grow as

Re: Finding a tuple in a tuple

2007-02-22 Thread Jussi Salmela
[EMAIL PROTECTED] kirjoitti: > Hi, > > Lists say I have the following tuple - > > t1 = ("ONE","THREE","SIX") > > and then the following tuples - > > t2 = ("ONE","TWO","THREE") > > t3 = ("TWO","FOUR","FIVE","SIX") > > t4 = ("TWO",) > > t5 = ("TWO","FIVE") > > What I want to do is return true

Re: Convert to binary and convert back to strings

2007-02-22 Thread Jussi Salmela
Steven D'Aprano kirjoitti: > On Wed, 21 Feb 2007 16:46:19 -0800, Harlin Seritt wrote: > >>> WARNING: THIS IS NOT A STRONG ENCRYPTION ALGORITHM. It is just a >>> nuisance for someone that really wants to decrypt the string. But >>> it might work for your application. >>> >>> -Larry >> Thanks Larry

Re: Convert to binary and convert back to strings

2007-02-22 Thread Jussi Salmela
Harlin Seritt kirjoitti: > Hi... > > I would like to take a string like 'supercalifragilisticexpialidocius' > and write it to a file in binary forms -- this way a user cannot read > the string in case they were try to open in something like ascii text > editor. I'd also like to be able to read the

Re: Sorting directory contents

2007-02-21 Thread Jussi Salmela
Larry Bates kirjoitti: > Wolfgang Draxinger wrote: >> Jussi Salmela wrote: >> >>> I'm not claiming the following to be more elegant, but I would >>> do it like this (not tested!): >>> >>> src_file_paths = dict() >>> prefix = sourc

Re: Sorting directory contents

2007-02-20 Thread Jussi Salmela
Wolfgang Draxinger kirjoitti: > Jussi Salmela wrote: > >> I'm not claiming the following to be more elegant, but I would >> do it like this (not tested!): >> >> src_file_paths = dict() >> prefix = sourcedir + os.sep >> for fname in os.listdir(s

Re: Sorting directory contents

2007-02-20 Thread Jussi Salmela
Wolfgang Draxinger kirjoitti: > H folks, > > I got, hmm not really a problem, more a question of elegance: > > In a current project I have to read in some files in a given > directory in chronological order, so that I can concatenate the > contents in those files into a new one (it's XML and I ha

Re: file io (lagged values) newbie question

2007-02-20 Thread Jussi Salmela
hiro kirjoitti: > Hey there, I'm currently doing data preprocessing (generating lagged > values for a time series) and I'm having some difficulties trying to > write a file to disk. A friend of mine, wrote this quick example for > me: > > > tweaked code: > ---

Re: can't find a way to display and print pdf through python.

2007-02-13 Thread Jussi Salmela
Dennis Lee Bieber kirjoitti: > On Tue, 13 Feb 2007 08:44:18 GMT, Jussi Salmela > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > >> On Windows, this (where fileName is xyz.PDF, for example): >> webbrowser.open(r'file://' + fil

Re: can't find a way to display and print pdf through python.

2007-02-13 Thread Jussi Salmela
Grant Edwards kirjoitti: > On 2007-02-12, Larry Bates <[EMAIL PROTECTED]> wrote: >> Grant Edwards wrote: >>> On 2007-02-12, Larry Bates <[EMAIL PROTECTED]> wrote: On 2007-02-12, Larry Bates <[EMAIL PROTECTED]> wrote: >>> I at least need the code for useing some library for >>> connecti

Re: Fwd: Python new user question - file writeline error

2007-02-08 Thread Jussi Salmela
Shawn Milo kirjoitti: > To the list: > > I have come up with something that's working fine. However, I'm fairly > new to Python, so I'd really appreciate any suggestions on how this > can be made more Pythonic. > > Thanks, > Shawn > > > > > > > Okay, here's what I have come up with: What f

Re: How can I use __setitem__ method of dict object?

2007-02-07 Thread Jussi Salmela
jeremito kirjoitti: > On Feb 7, 8:28 am, "jeremito" <[EMAIL PROTECTED]> wrote: >> On Feb 6, 5:10 pm, Bruno Desthuilliers >> >> >> >> <[EMAIL PROTECTED]> wrote: >>> jeremito a écrit : >>> > On Feb 6, 2:36 pm, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: >>> (snip) >>> >>Here's an alternative i

Re: Help with multiple key sort

2007-02-06 Thread Jussi Salmela
[EMAIL PROTECTED] kirjoitti: > gurus: > > I want to implement a sql-like sort-by on multiple keys. I've seen > many examples of just two keys. > > I have a list like this > > 1 one 2 > 1 one 1 > 1 two 1 > 1 one 0 > 1 xx 0 > > result should be like this > > 1 four 2 > 1 one 0 > 1 one 1 > 1 o

Re: Graphs, bar charts, etc

2007-02-06 Thread Jussi Salmela
Jan Danielsson kirjoitti: > Hello all, > >I have some data in a postgresql table which I view through a web > interface (the web interface is written in python -- using mod_python > under apache 2.2). Now I would like to represent this data as graphs, > bar charts, etc. > >I know about ma

Re: "flushing"/demanding generator contents - implications for injection of control

2007-02-05 Thread Jussi Salmela
metaperl kirjoitti: > For this program: > > def reverse(data): > for index in range(len(data)-1, -1, -1): > yield data[index] > > r = reverse("golf") > > for char in r: > print char > > > I'm wondering if the line: > > r = reverse("golf") > > "demands" the contents of the fun

Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Jussi Salmela
Stef Mientki kirjoitti: > Is it possible to change the searchpath for modules on the flight, > under winXP ? What do you mean by *on the flight*: inside IDLE? using the command line? > Most preferred is some command to extend the searchpath. > (the environment variable PYTHONPATH needs a reboot) >

Re: compound statement from C "?:"

2007-02-03 Thread Jussi Salmela
Peter Otten kirjoitti: > Isn't that obvious? Don't do it in one line: > > if n == 1: > print "I saw a car" > else: > print "I saw %d cars" % n > > I guess that most of us will have read, understood, and verified (are there > any errors or cases that should be covered but aren't) those fou

Re: compound statement from C "?:"

2007-02-03 Thread Jussi Salmela
[EMAIL PROTECTED] kirjoitti: > Jussi Salmela: >> In this particular case you don't need the ternary operator: >> print "I saw %d car%s\n" % (n, ("", "s")[n != 1]) > > The last newline is probably unnecessary. This seems be a bit more

Re: coping directories

2007-02-02 Thread Jussi Salmela
Gigs_ kirjoitti: > hi people > > I have problem with this example, not actually the problem, but > [code] > class FileVisitor(object): > def __init__(self, data=None): > self.context = data > def run(self, startdir=os.curdir): > os.path.walk(startdir, self.visitor, None) >

Re: compound statement from C "?:"

2007-02-02 Thread Jussi Salmela
Holger kirjoitti: > > I would like to do the equivalent if python of the C line: > printf("I saw %d car%s\n", n, n != 1 ? "s" : "") > > Please help > > /Holger > In this particular case you don't need the ternary operator: print "I saw %d car%s\n" % (n, ("", "s")[n != 1]) Cheers, Jus

Re: data design

2007-02-01 Thread Jussi Salmela
James Stroud kirjoitti: > > > > For instance, I have a copy_files section of a configuration. In order > to know what goes with what you have to resort to gymnastics with the > option names > > [copy_files] > files_dir1 = this.file that.file > path_dir1 = /some/path > > files_dir2 = the_othe

Re: One more regular expressions question

2007-01-18 Thread Jussi Salmela
Victor Polukcht kirjoitti: > Great thanks. > > You post helped me so much! > > My resulting regexp is: > "(?P^(.*)\s*)\(((?P\d+))\)\s+((?P\d+))" > If it doesn't have to be a regex: #=== s = '''\ Unassigned Number (1)

Re: A note on heapq module

2007-01-16 Thread Jussi Salmela
[EMAIL PROTECTED] kirjoitti: > I think the sort has to be simplified, otherwise it can't keep the heap > invariant... > > def sort(self): > self.h.sort() > > Bye, > bearophile > And __repr__ should be something like this: = def __repr__(self): if self.h: re

Re: Regular expressions question

2007-01-16 Thread Jussi Salmela
Victor Polukcht kirjoitti: > I have 2 strings: > > "Global etsi3 *200 ok30 100% 100% > Outgoing" > and > "Global etsi3 * 4 ok 30 100% 100% > Outgoing" > > The difference is "*200" instead of "* 4". Is there ability to write a > regula

Re: Why less emphasis on private data?

2007-01-08 Thread Jussi Salmela
Neil Cerutti kirjoitti: > On 2007-01-08, hg <[EMAIL PROTECTED]> wrote: >> sturlamolden wrote: >> >>> The designers of Java, C++, C#, Ada95, Delphi, etc. seem to think that >>> if an object's 'internal' variables or states cannot be kept private, >>> programmers get an irresistible temptation to mes

Re: Just Getting Started with Python on MS XP Pro

2007-01-08 Thread Jussi Salmela
W. Watson kirjoitti: > Gabriel Genellina wrote: >> On 7 ene, 16:20, "W. Watson" <[EMAIL PROTECTED]> wrote: >> >>> We seem to be looping. I have the Python interpreter. I would like the >>> pythonwin editor. The download link doesn't work on SourceForge. >>> Where can I >>> get it? If not there, wh

Re: how to find the longst element list of lists

2007-01-07 Thread Jussi Salmela
Michael M. kirjoitti: > How to find the longst element list of lists? > > I think, there should be an easier way then this: > > s1 = ["q", "e", "d"] > s2 = ["a", "b"] > s3 = ["a", "b", "c", "d"] > > > > After, the list ist sorted: > > sx1 = ["a", "b", "c", "d"] > sx2 = ["q", "e", "d

Re: Python cheatsheets

2007-01-07 Thread Jussi Salmela
gonzlobo kirjoitti: > Curious if anyone has a python cheatsheet* published? I'm looking for > something that summarizes all commands/functions/attributes. Having > these printed on a 8" x 11" double-sided laminated paper is pretty > cool. > > * cheatsheet probably isn't the right word, but you ge

Re: Just Getting Started with Python on MS XP Pro

2007-01-07 Thread Jussi Salmela
W. Watson kirjoitti: > Gabriel Genellina wrote: >> On 7 ene, 13:22, "W. Watson" <[EMAIL PROTECTED]> wrote: >> >> https://sourceforge.net/projects/pywin32/ >> >>> As I understand it, there are two files I'm after: 1. python >>> interpreter, >>> and 2. a python editor. It's #2 that I'm having tr

Re: still struggling, howto use a list-element as a name ? Sory, hit send button to early

2007-01-07 Thread Jussi Salmela
Stef Mientki kirjoitti: > In this exercise, I don't attempt to write "beautiful" Python code, > but the first thing is to write a simple "user-interface" for non-Pythians. > I understand that standardization about naming conventions is important, > but the purpose here is to serve the user, who has

Re: Just Getting Started with Python on MS XP Pro

2007-01-07 Thread Jussi Salmela
W. Watson kirjoitti: > Thomas Ploch wrote: >> https://sourceforge.net/projects/pywin32/ >> >> I think this is the place to go >> >> Thomas >> >> > That gets me the python program (pywin), which I got from a URL in a > post above (python-win.msi). I guess these are the same or at least just > th

Re: still struggling, howto use a list-element as a name ?

2007-01-06 Thread Jussi Salmela
Bruno Desthuilliers kirjoitti: > Stef Mientki a écrit : >> In the example below, "pin" is an object with a number of properties. >> Now I want >> 1- an easy way to create objects that contains a number of these "pin" >> 2- an multiple way to access these "pin", i.e. >> device.pin[some_index

Re: howto overload with a NOP (empty statement)

2007-01-06 Thread Jussi Salmela
Bruno Desthuilliers kirjoitti: > Stef Mientki a écrit : >> How should I overload / disable a method ? >> In the example below I have defined the class "Power_Supply", derived >> from baseclass "device". > > > Naming conventions are to use CamelCase for class names. So it would be > better to na

Re: Learning to program in Python

2007-01-05 Thread Jussi Salmela
Demel, Jeff kirjoitti: > If I were you, I'd think up a project and just build it. The best way > to really learn is to do, at least for me. If you run into problems, > then you can come back and ask the group here. Believe me, I've asked > some very basic questions, and everyone's been very frie

Re: where is Microsoft Speech Object Library 5.1 option inPythonWin 2.5?

2007-01-05 Thread Jussi Salmela
happy. == New Email Notifier.py == #!/usr/bin/python ''' License: MIT License. See License.txt. If that file is not attached, the license is http://www.opensource.org/licenses/mit-license.php, where = 2006 and = Jussi

Re: question on creating class

2007-01-04 Thread Jussi Salmela
wcc kirjoitti: > Hello, > > How do I create a class using a variable as the class name? > > For example, in the code below, I'd like replace the line > > class TestClass(object): > with something like > class eval(className) (object): > > Is it possible? Thanks for your help. > > className =

Re: array of class / code optimization

2007-01-03 Thread Jussi Salmela
hg kirjoitti: > mm wrote: > >> Yes, it was the (), equivalent to thiks like new() create new object >> from class xy. >>> s1.append(Word) >> s1.append(Word()) >> >> But I was looking for a "struct" equivalent like in c/c++. >> And/or "union". I can't find it. >> >> Maybe you know a source (URL)

Re: import order or cross import

2007-01-03 Thread Jussi Salmela
Roland Hedberg kirjoitti: > Hi! > > I'm having a bit of a problem with import. > > I'm writing a marshalling system that based on a specification will > create one or more files containing mostly class definitions. > > If there are more than one file created (and there are reasons for > creating

Re: When Closure get external variable's value?

2006-12-18 Thread Jussi Salmela
Huayang Xia kirjoitti: > It will print 15. The closure gets the value at run time. > > Could we treat closure as part of the external function and it shares > the local variable with its holder function? > I don't quite get what you are trying to tell us but if you think that in your example co

Re: def index(self):

2006-12-18 Thread Jussi Salmela
Gert Cuykens kirjoitti: > Is there a difference between > > > class HelloWorld: > def index(self): > index.exposed = True > return "Hello world!" > > > and > > > class HelloWorld: > def index(self): > self.exposed = True > return "Hello world!" > The resident experts seemingly being abs

Re: How to replace a comma

2006-12-18 Thread Jussi Salmela
Lad kirjoitti: > > Thank you for ALL for help. > Hendrik, > your solution works great but > what is `_` in > _.replace(',',', ') > > for? When you are trying things out in the Python shell IDLE, _ is a shorthand way to use the last value printed by IDLE. Thus when s.replace(', ',',') p

Re: not a big deal or anything, but, curiously:

2006-12-13 Thread Jussi Salmela
gatcgggctaa""".replace("\n","") >> >> gc = float(count(cds, 'g') + count(cds, 'c'))/ len(cds) >> >> print gc >> >> -fin- >> >> which should yield: 0.54460093896713613.. >> >> but when I ran it I got: 0.544600938967 >> >> looking now I see it's truncating after a certain number of decimal >> places. any ideas why? > > Read the Python Tutorial appendix on floating-point issues: > >http://docs.python.org/tut/node16.html > > As it says, str(a_float) rounds to 12 significant digits, and > repr(a_float) to 17. The `print` statement implicitly applies str() > to each item it prints. Cheers, Jussi Salmela -- http://mail.python.org/mailman/listinfo/python-list

Re: Large files uploading

2006-12-13 Thread Jussi Salmela
ocumentation on 'ftplib -- FTP protocol client'. It has an example to get you started. HTH, Jussi Salmela -- http://mail.python.org/mailman/listinfo/python-list

Re: Libgmail

2006-11-28 Thread Jussi Salmela
linuxfreak wrote: > Funny enough I find the same "Google" in my browser too. and if my > memory serves me correct I did the same search which you allude to. It > is only after series of exhaustive searches rummaging through websites > with incomplete (or non existent ) docs that i posed the questi

Re: Libgmail

2006-11-28 Thread Jussi Salmela
linuxfreak wrote: > hi guys, > > just starting out on python and libgmail... any documentation for > libgmail outthere... basically what i want to do is develop an > application to use gmail like and ftp server... should be able to > upload files and download them as well > > thanks > My b

Re: python skipping lines?

2006-11-27 Thread Jussi Salmela
[EMAIL PROTECTED] wrote: > RawData = open('/Python25/working/data.txt', 'r') You open this file only once. The first time in here: > def PullHourlyData(filename, facility, unit): > for line in filename: reads all of the file - nothing left for the other function calls! A better way wou

Re: question about function not executing

2006-11-26 Thread Jussi Salmela
Ara Kooser wrote: > When I run the python program it works fine until I try to go west > from my inital start room. I get the room description but no raw_input > prompt. I just get dumped back to >>> in the python shell. I think I > am missing something simple. I pasted in the code below. I am us

Re: How to choose the right GUI toolkit ?

2006-11-11 Thread Jussi Salmela
th my own meter and to produce a PDF page with PyChart to hand to my doctor to inspect when I visit him twice a year. Cheers, Jussi -- Jussi Salmela http://personal.inet.fi/cool/operator/ -- http://mail.python.org/mailman/listinfo/python-list