Re: annoying stdin/stdout + pipes problem

2007-09-24 Thread per9000
On 23 Sep, 18:24, Damjan <[EMAIL PROTECTED]> wrote: > > I want to create a program that reads input from stdio that can prompt > > a user for input while doing so without getting into problems. > ... > > The trick (which works on Linux for sure) is to open /dev/tty and ask > question/get input on/f

annoying stdin/stdout + pipes problem

2007-09-23 Thread per9000
Hi, I want to create a program that reads input from stdio that can prompt a user for input while doing so without getting into problems. A simplified version of what I want: I have an input file ***>cat input.txt foo bar baz fubar barooba xyxxyt raboof txet black knight And a file that replaces

encrypting files + filestreams?

2007-08-15 Thread per9000
Hi python people, I am trying to figure out the best way to encrypt files in python. I've build a small script (see below) that encrypts the ubuntu 7.04 iso file in 2 minutes (I like python :) ). But I have some thoughts about it. By pure luck (?) this file happened to be N*512 bytes long so I d

Re: magic names in python

2007-06-05 Thread per9000
ererikstrandberg.se work: www.incf.org also: www.spongswedencare.se > > On Jun 4, 2:43 pm, per9000 <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I recently started working a lot more in python than I have done in > > the past. And I discovered something that tota

Re: magic names in python

2007-06-05 Thread per9000
On 4 Juni, 10:19, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > > [...] > > Now I'm a little confused. What does this have to do with magic names? I > thought you are talking about names that start and end with two > underscores (`__magic__`)!? Indeed I am talking about two things at onc

Re: magic names in python

2007-06-04 Thread per9000
On Jun 4, 9:11 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, per9000 wrote: > > > > [...] > > > > So another question emerges: > > * is the use of magic names encouraged and/or part of good coding > >

magic names in python

2007-06-03 Thread per9000
Hi, I recently started working a lot more in python than I have done in the past. And I discovered something that totally removed the pretty pink clouds of beautifulness that had surrounded my previous python experiences: magic names (I felt almost as sad as when I discovered the strange pink worm

Re: test

2007-05-03 Thread per9000
On 2 Maj, 05:19, "Robert Rawlins - Think Blue" <[EMAIL PROTECTED]> wrote: [...] I like comp.lang.python - it is a friendly place. See this post on the C-list and compare: http://groups.google.se/group/comp.lang.c/browse_thread/thread/0a4e2e194a6da45b [:)]-|--< /Per -- Per Erik Strandberg .NET

Re: ctypes and pointers

2007-04-16 Thread per9000
[This might be a double posting, if it isn't my previous post was lost] Look up "restype" in the ctypes library - it sets the return type from a function. You may want to set it to c_void_p of something similar, instead of the default int. I made a similar discovery in my blog - http://www.pereri

Re: reaching hidden methods + casting

2007-04-12 Thread per9000
On 12 Apr, 09:42, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > > > > In f.x. the C-family of languages I guess something like this would > > call B.spin: > > ((B)myC).spin("Lancelot"); // almost forgot the ';' > > Try this in Python: > B.spin(myC, "Lancelot") > > > > Thanks, that was exac

reaching hidden methods + casting

2007-04-12 Thread per9000
Hi, can I reach a hidden method when doing ugly inheritance in python? >>> class A: ... def spin(self, n): print "A", n ... >>> class B: ... def spin(self, m): print "B", m ... >>> class C(A,B): ... def spin(self, k): print "C", k ... >>> myC = C() >>> dir(myC) ['__doc__', '__module__'

Re: PDF with nonLatin-1 characters

2006-07-13 Thread per9000
Stefan Behnel wrote: > victor wrote: > > I want to generate a report and the PDF fits perfectly. Though there is > > an issue of using different encoding in the doc. I tried PyPS with no > > success. I need a lib that can make PDFs with an arbitrary set of fonts > > (possibly embed them into the do

Re: Python CGI Scripting Documentation

2006-07-03 Thread per9000
uess, I don't know why, but it works...) The file had to be named filetitle + ".cgi" because of some setting at my web hotel. Good luck! /Per9000 -- http://mail.python.org/mailman/listinfo/python-list

Re: compiling python (or ironpython) to .exe or .dll for or not for .NET

2006-06-28 Thread per9000
Update: I have found a holy handgrenade. I found something that seems to work fine for me - I've only tried it for 5 minutes but seems to work very smoothly. Open-source, Mozilla license, you know the drill... http://www.py2exe.org/ py2exe (the name makes me fall in love) creates some dll's for

compiling python (or ironpython) to .exe or .dll for or not for .NET

2006-06-28 Thread per9000
Hi python people, I am working with .NET (in C++/CLI and C#) but since I really love python I'd like to do things for .NET (or whatever) from python. Has anyone tried it? What (costless) compilers are good? Are there any (costless) editors like MS Visual Express you have tried? Is the newest I

Re: How to truncate/round-off decimal numbers?

2006-06-21 Thread per9000
Nick Maclaren wrote: > |> just a thought: if you *always* work with "floats" with two decimals, > |> you are in fact working with integers, but you represent them as a > |> floats - confusing for the internal representation. > > No, you aren't - you are working with fixed-point Nick, your answer h

Re: How to truncate/round-off decimal numbers?

2006-06-21 Thread per9000
oops, should be something like this: "int / int" = "int / int, int % int" /per9000 -- http://mail.python.org/mailman/listinfo/python-list

Re: How to truncate/round-off decimal numbers?

2006-06-21 Thread per9000
ndoffs etc when dividing. "int (+|-|*) int" = int "int / int" = int / int + int % int Integers are nice, me like integers. /per9000 -- http://mail.python.org/mailman/listinfo/python-list

Re: create a text file

2006-05-31 Thread per9000
Ooops, w must be 'w' - sorry for adding more confusion :-D I would also like to add that this is a more realistic useage appendix = '.txt' # or '.csv' or whatever # some code c += 1 filetitle = 'result_' + zeropadding(c) + str(c) myfile = open(filetitle+appendix,'w') # etc Hope that was a l

Re: create a text file

2006-05-30 Thread per9000
Hi, This is what I often do: somekindofoutput = '' somekindofoutput += somefunk(somearg) + '\n' # w is for writing myfile = open('theoutfile',w) myfile.write(somekindofoutput) myfile.close() also see http://www.python.org/doc/2.3.5/tut/node9.html or some other documentation /P9k -- http://ma

Re: Very good Python Book. Free download : Beginning Python: From Novice to Professional

2006-05-30 Thread per9000
ndomchoice(["is","could be"]) a great book. Please read and/or add if you are one of the nice guys. Ciao, PER9000 "It is a gift. A gift to the foes of 'the Terrorists'. Why not use this 'terrorism'? Long has my father, 'George Bush', kept

Re: how to change sys.path?

2006-05-25 Thread per9000
also se topic named 'problem(s) with import from parent dir: "from ../brave.py import sir_robin" ' I use this every day now: sys.path.append("../../py_scripts") best wishes, Per -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 3.0 or Python 3000?

2006-04-11 Thread per9000
I can't wait to get my hands on version PAL9000, then we will all have to deallocate memory *the hard way*. /per9000 --- I'm afraid. I'm afraid, Dave. Dave, my mind is going. I can feel it. I can feel it. My mind is going. There is no question about it. I

Re: Automated Graph Plotting in Python

2006-04-10 Thread per9000
Dear shrub-makers, if you are want to plot networks (fx. genetic networks) I can recommend Cytoscape: http://cytoscape.org/ (some kind of openware). The in-syntax is clean: node1 linktype1 node2 node2 linktype1 node3 node3 linktype2 node1 etc. But in general you are going to want to change the l

Re: Counting number of each item in a list.

2006-03-20 Thread per9000
Dear counters, I have also encountered the above problem, and I frequently use the two blocks of code below. The first one is commented already - except that this version does not start from an empty dict. The second "inverts" the first one. Meaning that a dict in word2hits style: my_dict['the'

Re: problem(s) with import from parent dir: "from ../brave.py import sir_robin"

2006-02-24 Thread per9000
...and there was much rejoicing... Even better, thanks - you guys are the best. import string, time, sys sys.path.append("../../py_scripts") Works just nice, and yes, I removed the env.variable before I tried it :-D /Per9000 -- http://mail.python.org/mailman/listinfo/python-list

Re: problem(s) with import from parent dir: "from ../brave.py import sir_robin"

2006-02-24 Thread per9000
Thanks, I added an environment variable PYTHONPATH and added the holy folder with my script in. Works just perfectly. But still: is there a way around this? (It is a lot easier to add "../../" in my code than make everyone else add this variable). /per9000 -- http://mail.python.o

problem(s) with import from parent dir: "from ../brave.py import sir_robin"

2006-02-24 Thread per9000
se give me, not a bucket with the desert(s) on top, but just the thin chocolate? /per9000 (per nine thousand at gmail dot com) LONG VERSION: Since I do not want to use absoute paths I want to import a file from two folders up and then one down. This problem seems to be discusse