Re: Bizarre floating-point output

2007-01-08 Thread Bjoern Schliessmann
Nick Maclaren wrote: > I think that you should. Big words. > Where does it say that tuple's __str__ is the same as its > __repr__? Where does it say that a tuple's __str__ does not call its contents' __repr__? > The obvious interpretation of the documentation is that a sequence > type's __str

Re: Bizarre floating-point output

2007-01-08 Thread Bjoern Schliessmann
Nick Maclaren wrote: > The use of different precisions for the two cases is not, however, > and it is that I was and am referring to. You mistake "precision" with "display". Regards, Björn -- BOFH excuse #12: dry joints on cable plug -- http://mail.python.org/mailman/listinfo/python-list

Re: newbieee

2007-01-08 Thread Bjoern Schliessmann
lee wrote: > I getting familiarised with python...can any one suggest me a good > editor available for python which runs on windows xp Look here: http://wiki.python.org/moin/PythonEditors > one more request guys...can nyone tell me a good reference manual > for python.. Either the python ho

Re: Bizarre floating-point output

2007-01-08 Thread Bjoern Schliessmann
Nick Maclaren wrote: > Not at all. "Precision" has been used to indicate the number of > digits after the decimal point for at least 60 years, Not only, remember: Computer memories can't think in powers of ten. > probably 100; in 40 years of IT and using dozens of programming > languages, I ha

Re: Maths error

2007-01-08 Thread Bjoern Schliessmann
Rory Campbell-Lange wrote: > Is using the decimal module the best way around this? (I'm > expecting the first sum to match the second). It seem > anachronistic that decimal takes strings as input, though. What's your problem with the result, or what's your goal? Such precision errors with floatin

Re: Execute binary code

2007-01-08 Thread Bjoern Schliessmann
Larry Bates wrote: > What you are asking is a virus/trojan "like" program. Why? For being a trojan horse it must fake something. For being a virus it must replicate itself. Writing an executable doesn't imply the will to replicate itself. But you could technically achieve this with standard pyt

Re: Execute binary code

2007-01-08 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > The code I try to execute is Windows specific and it is binary, > not python. Furthermore, it is stored in a variable within the > parent python script, not stored on harddisk as a file. Sure, I just wanted to show that your special application is not specific for troja

Re: Maths error

2007-01-09 Thread Bjoern Schliessmann
Nick Maclaren wrote: > No, don't. That is about another matter entirely, It isn't. Regards, Björn -- BOFH excuse #366: ATM cell has no roaming feature turned on, notebooks can't connect -- http://mail.python.org/mailman/listinfo/python-list

Re: help: code formatter?

2007-01-09 Thread Bjoern Schliessmann
siggi wrote: > Bjoern wrote: >> Why don't you just write one? :) > > Very funny! Just learning Python :( It isn't funny at all. You'll learn by doing and trying things. That's how all programmers start. Regards, Björn -- BOFH excuse #265: The mouse escaped. -- http://mail.python.org/ma

strange PyLint configuration (was: PEP 8 style enforcing program)

2007-05-31 Thread Bjoern Schliessmann
Alexander Eisenhuth wrote: > Pylint is one of them (http://www.logilab.org/857) BTW: Why does pylint want all names with underscores? I tested it and it complains about malformed names in e.g. the following cases that are conformant to PEP 8: - single letter as parameter - firstLowerCamelCase na

Re: strange PyLint configuration

2007-05-31 Thread Bjoern Schliessmann
Eduardo "EdCrypt" O. Padoan wrote: > No. Quoting PEP 8: > Functions: > """ > mixedCase is allowed only in contexts where that's already the > prevailing style (e.g. threading.py), to retain backwards > compatibility. > """ > Methods and instances: > """ > Use the function naming rules:

Re: Python Pop Quiz

2007-06-02 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > Bonus: A rabbi walks into a bar while nursing a baby goat. He is > closely followed by a priest, and a Perl hacker. Explain. Getting religious, eh? :) http://xkcd.com/c224.html Regards, Björn -- BOFH excuse #14: sounds like a Windows problem, try calling Microso

Re: Who uses Python?

2007-06-04 Thread Bjoern Schliessmann
walterbyrd wrote: > Anything else? Finance? Web-analytics? SEO? Digital art? We're using Python for a computer-controlled railway simulation system at a german university. It consists of a rather large model railway network, constructed with realism concerning railway operations, coupled to reali

Re: Determinant of Large Matrix

2007-06-06 Thread Bjoern Schliessmann
James Stroud wrote: > For this matrix, I'm getting this with numpy: > > 2774532095.971 > > But I have a feeling I'm exceeding the capacity of floats here. > Does anyone have an idea for how to treat this? Not if you don't state your requirements more precisely. E. g. what precision do you n

Re: Help a C++ escapee!

2007-06-07 Thread Bjoern Schliessmann
Simon Pickles wrote: > from socket import * Bad idea, can make conflicts in namespace. > import threading There's absolutely no need to use threads for a server that accepts multiple connections :) > class CNetworkManager(): Note that you create an "old style" class. For new style classes, i

Re: Determinant of Large Matrix

2007-06-07 Thread Bjoern Schliessmann
James Stroud wrote: > If I run it again on 10 (or 1000) the set is basically homogenous > but now of different values (terribly confusing): > > set([12048175104.1, 12048175104.15, 12048175104.46, > 12048175103.94, 12048175104.23, 12048175103.81, > 12048175103.98, 12048

Re: python integration

2007-06-08 Thread Bjoern Schliessmann
Dee Asbury wrote: > I am looking for a method to integrate in Python, my problem is > that I do not want the summed up result. I need the result in the > form of a list (or array) with the x-values (or ranges) and the > volume beneath that section of the curve only. Why don't you then split up y

Re: Python's "only one way to do it" philosophy isn't good?

2007-06-09 Thread Bjoern Schliessmann
Gabriel Genellina wrote: > For what I can > remember of my first love (Physics): if you have a small ball > moving inside a spherical cup, it would be almost crazy to use > cartesian orthogonal coordinates and Newton's laws to solve it - > the "obvious" way would be to use spherical coordinates an

Re: poking around a running program

2007-06-15 Thread Bjoern Schliessmann
Paul Rubin wrote: > Is this kind of thing common? Has it been done before and are > there some recipes? The Twisted framework offers an interactive Python shell inside the application (Twisted manhole). Regards, Björn -- BOFH excuse #249: Unfortunately we have run out of bits/bytes/whate

Re: IndentationError: unexpected indent

2007-06-15 Thread Bjoern Schliessmann
"Wim Vogelaar" wrote: > You have possibly unvisible tab characters in your file. > Just copy your lines to the simple MS notepad and try again. How is he supposed to run MS notepad on X11? :) Regards, Björn P.S.: YES, I know there is wine. -- BOFH excuse #126: it has Intel Inside -- htt

Re: Python IDE

2007-06-19 Thread Bjoern Schliessmann
BartlebyScrivener wrote: > VIM *clap-clap* BTW, are there tutorials on the more arcane vim functions that come in handy with Python? Regards, Björn -- BOFH excuse #168: le0: no carrier: transceiver cable problem? -- http://mail.python.org/mailman/listinfo/python-list

Re: static python classes ?

2007-06-19 Thread Bjoern Schliessmann
Diez B. Roggisch wrote: > With other OOP languages you mean Java. Which does have static > methods because they lack the notion of a function by its own, so > the shoehorned them into their "everything is inside a > class"-paradigm. ACK, but doesn't C++ have static methods too? Regards, Björn

Re: Python IDE

2007-06-19 Thread Bjoern Schliessmann
William Allison wrote: > Not a tutorial, but I found this little snippet: > > http://www.ibiblio.org/obp/pyBiblio/tips/elkner/vim4python.php > > I thought the last line was especially neat. Nice. Thanks to you two, I'm going to try that out. Regards, Björn -- BOFH excuse #414: tachyon emi

Re: Python and (n)curses

2007-06-19 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > On Jun 19, 3:27 pm, Ben Finney >> And as "peter" mentions, it awaits only someone doing that work >> and contributing it to Python. Those who can't see why it would >> be hard are welcome to do so. > > The classic answer. Yes, because of the classic problem with unsala

Re: Globals in nested functions

2007-06-21 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > def f(): > a = 12 > def g(): > global a > if a < 14: > a=13 > g() > return a > > print f() > > This function raises an error. Is there any way to access the a in > f() from inside g(). Yes. Pass it to g when calling the latt

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-21 Thread Bjoern Schliessmann
Stephen R Laniel wrote: > On Wed, Jun 20, 2007 at 12:59:28PM -0700, > [EMAIL PROTECTED] wrote: >> Then you should use another language. > > This is what I meant about knowing how Internet discussions > go. I agree. I also notice that (rather newbie-) OPs with not-so-simple questions are easily o

Re: Error in following code

2007-06-23 Thread Bjoern Schliessmann
Jay Loden wrote: > That should do the trick. Additionally, it does the trick to save the first entered number as default argument forever. Regards, Björn -- BOFH excuse #117: the printer thinks its a router. -- http://mail.python.org/mailman/listinfo/python-list

Re: Collections of non-arbitrary objects ?

2007-06-24 Thread Bjoern Schliessmann
7stud wrote: > On Jun 23, 11:45 am, walterbyrd <[EMAIL PROTECTED]> wrote: >> Suppose you are sequentially processing a list with a routine >> that expects every item to be of a certain type. Something in the >> list that doesn't conform to the type could give you unexpected >> results, maybe crash

Re: Python SVN down?

2007-06-25 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > Going to this URL: > http://svn.python.org/view/ > > It gives me an error: > Unable to connect > Firefox can't establish a connection to the server at > svn.python.org. > [...] > Any ideas? Clear case. $ nc -v svn.python.org 80 svn.python.org [82.94.237.220] 80 (www)

Re: Chroot Jail Not Secure for Sandboxing Python?

2007-06-25 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > I followed up with my ISP. Here's the answer I got: > > The os.exec call prepends the chroot directory to the absolute > path, but does NOT provide chroot for the child process. That sounds like rubbish to me. If it worked like that, chrooting servers would be virtu

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-27 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > I'm currently using Python. How long have you been using Python? > I find that a instance variable > must confined with self, for example: > class a: > def __init__(self): > self.aa=10 > def bb(self): > print self.aa # > See .if in c++,I coul

Re: Too many 'self' in python.That's a big flaw in this language.

2007-06-28 Thread Bjoern Schliessmann
Alex Martelli wrote: > Bjoern Schliessmann <[EMAIL PROTECTED]> > wrote: >> Mh, strange, I personally like to use "this.a" in C++, to make >> clear I use an instance variable. > That would be nice, unfortunately your C++ compiler will refuse > that, and fo

Re: PEP 3107 and stronger typing (note: probably a newbie question)

2007-06-28 Thread Bjoern Schliessmann
Bruno Desthuilliers wrote: > John Nagle a écrit : >> Actually, static typing is for detecting errors before the >> program is run. > > [EMAIL PROTECTED] ~ $ gcc -ototo toto.c > [EMAIL PROTECTED] ~ $ ./toto > Erreur de segmentation > [EMAIL PROTECTED] ~ $ > > You said ? Did he say that static

Re: subprocess -- broken pipe error

2007-07-02 Thread Bjoern Schliessmann
7stud wrote: > Thanks for the response. So are you saying that the only way you > can get data out of a pipe is when the subprocess has terminated? No, not only because Pipes aren't related to processes in any special way. He said that you can't write to a pipe whose reader has already terminat

Re: subprocess -- broken pipe error

2007-07-02 Thread Bjoern Schliessmann
7stud wrote: > Why doesn't the following program write to the file? > [...] > It just hangs, and then when I hit Ctrl+C and look in the file, > the data isn't in there. I suppose your running child process isn't closed cleanly if you terminate the parent process. Also, the pipe may be unbuffered

Re: newbie-question

2007-07-03 Thread Bjoern Schliessmann
TK wrote: > how can I implement a socket timeout? What exactly do you mean by "socket timeout"? Which OS? > Thanx for help. Thanks for choosing an adequate subject next time. Regards, Björn -- BOFH excuse #84: Someone is standing on the ethernet cable, causing a kink in the cable -- htt

Re: ImportError: "No Module named xxx"

2007-07-06 Thread Bjoern Schliessmann
Robert Dailey wrote: > The description of -m is confusing in the documentation, what does > it really do? IMHO, it's quite clear. What's unclear with this description: -m module-nameSearches sys.path for the named module and runs the corresponding .py file as a script. Reg

Re: What is the most efficient way to test for False in a list?

2007-07-09 Thread Bjoern Schliessmann
Paul Rubin wrote: > lex <[EMAIL PROTECTED]> writes: >> list = [1, True, True, False, False, True] >> status = True >> for each in list: >> status = status and each >> >> but what is your best way to test for for False in a list? > > status = all(list) Am I mistaken, or is this no identity t

Re: What is the most efficient way to test for False in a list?

2007-07-09 Thread Bjoern Schliessmann
Diez B. Roggisch wrote: > Bjoern Schliessmann wrote: >> Paul Rubin wrote: >>> lex <[EMAIL PROTECTED]> writes: >>>> but what is your best way to test for for False in a list? >>> >>> status = all(list) >> >> Am I mistaken, or is

Re: Class file location

2007-07-09 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > Is there a way to define a different directory for the generated > .class(*$py.class) files than the current directory where the > python scripts are located and executed from? Excuse me, since when does python generate .class files? Regards, Björn -- BOFH excuse #4

Re: What is the most efficient way to test for False in a list?

2007-07-09 Thread Bjoern Schliessmann
Paul Rubin wrote: > Bjoern Schliessmann <[EMAIL PROTECTED]> > writes: >> That's an identity test for True, not for False (the latter was >> requested). Thus, I'm not mistaken. > > No, "true" is not the same thing as "True". Oops, read

Re: Should I use Python for these programs?

2007-07-10 Thread Bjoern Schliessmann
Grant Edwards wrote: > Most of the graphics I do with Python is with Gnuplot (not > really appropriate for what you want to do. > wxWidgets/Floatcanvas might be worth looking into. Agreed (I'm quite sure you mean wxPython though). Also, in "wxPython in Action" (the official book) a simple drawing

Re: highly einteractive editor for python

2007-07-10 Thread Bjoern Schliessmann
Atul Bhingarde wrote: > What I want to see is that it is possible to create a python based > application in a environment where I can see the results as I am > creating it, specifically gui widgets (from say TK). This will > provide a robust mechanism to see gui layout as well. Py is an IDE for P

Re: bool behavior in Python 3000?

2007-07-10 Thread Bjoern Schliessmann
Alan Isaac wrote: > Hoping the bool type will be fixed will be fixed, Is there any type named "bool" in standard Python? Regards, Björn -- BOFH excuse #207: We are currently trying a new concept of using a live mouse. Unfortunately, one has yet to survive being hooked up to the computer...

Re: bool behavior in Python 3000?

2007-07-10 Thread Bjoern Schliessmann
Alan G Isaac wrote: > My preference would be for the arithmetic operations *,+,- > to be given the standard interpretation for a two element > boolean algebra: > http://en.wikipedia.org/wiki/Two-element_Boolean_algebra >>> [bool(True+True), bool(True+False)] [True, True] Works for me, or did I m

Re: Best architecture for proxy?

2007-07-10 Thread Bjoern Schliessmann
Andrew Warkentin wrote: > I am going to write a general-purpose modular proxy in Python. It > will consist of a simple core and several modules for things like > filtering and caching. I am not sure whether it is better to use > multithreading, or to use an event-driven networking library like > T

Re: bool behavior in Python 3000?

2007-07-12 Thread Bjoern Schliessmann
Alan Isaac wrote: > Bjoern Schliessmann wrote: >> Is there any type named "bool" in standard Python? >>>> type(True) > Thanks anyway, but I remembered it shortly after sending. Thus the cancel (seems to have failed a bit). Regards, Björn -- BOFH e

Re: bool behavior in Python 3000?

2007-07-12 Thread Bjoern Schliessmann
Steven D'Aprano wrote: > It seems to me that you deliberately misunderstood him. I know for sure I didn't. > Why else would you type-cast the integers 2 and 1 to bools to > supposedly demonstrate that there's nothing wrong with operations > between bools returning ints? Kindly excuse me bother

Re: NoneType object not iterable

2007-07-13 Thread Bjoern Schliessmann
Daniel wrote: > db is out of scope, you have to pass it to the function: What's wrong about module attributes? Regards, Björn -- BOFH excuse #418: Sysadmins busy fighting SPAM. -- http://mail.python.org/mailman/listinfo/python-list

Re: Private functions and inheritance

2007-07-16 Thread Bjoern Schliessmann
Maciej Blizi?ski wrote: > calling B::call_bar(): B::bar() > calling B::call___bar(): A::__bar() (BTW, there is no :: operator in Python. It should be, e. g., B.bar().) > In the latter case, it calls the base class' implementation. It > probably goes along with Python's spec, but I found it surp

Re: Discover instance variables

2007-07-16 Thread Bjoern Schliessmann
JonathanB wrote: > Ok, I know there has to be a way to do this, but my google-fu > fails me (once more). I have a class with instance variables (or > should they be called attributes, I'm newish to programming and > get really confused with OO sometimes), To complete confusion, those terms vary wi

Re: Discover instance variables

2007-07-18 Thread Bjoern Schliessmann
JonathanB wrote: > So given that example, is there a clean way to get this output: > > Data for Earth: > Name = Earth > WTN = 5.0 > Ag = 0 > Na = 0 > ... > ... > Notes = None Sure, save the __init__ parameters explicitly in a dict. self.data = {"Name": name, "WTN": WTN,

Re: Converting between objects

2007-07-19 Thread Bjoern Schliessmann
Nathan Harmston wrote: > is there way I can define conversion functions like this: > > say i have a class A and a class B > > bobj = B() > aobj = a(bobj) > > in a neater way than just defining a set of methods > > def a(object_to_convert) > # if object_to_convert of type.. > # do s

Re: Permutations with generators

2007-07-21 Thread Bjoern Schliessmann
Pablo Torres wrote: > AttributeError: 'NoneType' object has no attribute 'insert' > > Could somebody please explain to me why my p variable has no type > at all? It does have a type, NoneType. As already explained, only None normally is of type NoneType. Regards, Björn -- BOFH excuse #281:

Re: Sorting dict keys

2007-07-21 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > I'd like to do it in one line because what I am trying to do is, > after all, a single, simple enough action. No, it's two actions: 1. You extract a list of keys from the dict 2. you sort it > I find the suggested b = sorted(a.keys()) much more readable than > brea

Re: Advice on sending images to clients over network

2007-07-22 Thread Bjoern Schliessmann
Frank Millman wrote: > My question is, what is the best way to get the image to the > client? IMHO, HTTP would be most painless. Either incorporate a little HTTP server into your server application, or use a seperate daemon and let the server only output HTTP links. > My third thought was to se

Re: When are immutable tuples *essential*? Why can't you just use lists *everywhere* instead?

2007-04-20 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > Please help me think of an example where immutable tuples are > essential. When used as dictionary keys (also everywhere else where they must be in a constant order). Yes, this *is* used in practice. Regards, Björn -- BOFH excuse #14: sounds like a Windows probl

Re: When are immutable tuples *essential*? Why can't you just use lists *everywhere* instead?

2007-04-20 Thread Bjoern Schliessmann
Luis M. González wrote: > I don't remember exactly where I read about it, but Guido said > once that tuples are being kept mainly for historical reasons. Weren't tuples added when lists already existed? Regards, Björn -- BOFH excuse #101: Collapsed Backbone -- http://mail.python.org/mailm

Re: Python Feature Request: Explicit variable declarations

2007-04-20 Thread Bjoern Schliessmann
Dennis Lee Bieber wrote: > Unless it should be interpreted as (C/C)++, which would result in > 2 No, since postfix ++ "returns before and increments after". But what you say is true for ++(C/C). Regards, Björn -- BOFH excuse #274: It was OK before you touched it. -- http://mail.python.org

Re: Select weirdness

2007-04-22 Thread Bjoern Schliessmann
Ron Garret wrote: > print>>self.wfile, 'HTTP/1.0 200 OK' > print>>self.wfile, 'Content-type: text/plain' > print>>self.wfile > print>>self.wfile, 'foo' > [...] > If I telnet into this server and type in an HTTP request manually > it works fine. But when I try to access this with a

Re: python style guide inconsistencies

2007-04-22 Thread Bjoern Schliessmann
Darren Dale wrote: > I was just searching for some guidance on how to name packages and > modules, and discovered some inconsistencies on the > www.python.org. http://www.python.org/doc/essays/styleguide.html > says "Module names can be either MixedCase or lowercase." That > page also refers to PE

Re: How to find complementary colour for pixel

2007-04-26 Thread Bjoern Schliessmann
Johny wrote: > As pictures maybe different, colour, in the position where I > write the text, is also different. > Is there a way how to set the font colour so that it will be seen > very clearly in the picture? > For example, if the picture is bright ( for example yellow), the > font colour shou

Re: Access to raw command line?

2007-04-26 Thread Bjoern Schliessmann
Pieter Edelman wrote: > ./myprog.py -t *.gpx *.jpg > > This seems like a sensible option at first sight, but it's > difficult to implement because the wildcard is expanded by the > shell, (in *nix only) > so sys.argv gets a list containing "-t", all .gpx files and > all .jpg files. With this

Re: My python annoyances so far

2007-04-26 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > Hi all. I'm learning python these days. I'm going to use this > thread to post, from time to time, my annoyances with python. I > hope someone will clarify things to me where I have misunderstood > them. > > Annoyances: > > 1. Underscores! What's the deal with that? Es

Re: My python annoyances so far

2007-04-26 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > Hi. You wrote c++, didn't you? Yes :) But I mostly don't anymore and ported my main project from C++ to Python. > Well, why do some things in the library have to be functions, and > other things have to be class methods? Easy. Some things abstractly operate on all kin

Re: Atribute error

2007-04-26 Thread Bjoern Schliessmann
gtb wrote: > In file Test1.py below I get a attribute error on the line > "self.logon()". Seems like the class doesn't have this attribute. > It worked earlier when Test1 was derived from > class newLogon but that does not seem logical to me. What's the definition of CompactTest? Regards,

Re: My python annoyances so far

2007-04-27 Thread Bjoern Schliessmann
James Stroud wrote: > Here is something on which to meditate: classes become functions > when you get the quantum mechanics just so! s/become/can behave like/ :) Regards, Björn -- BOFH excuse #27: radiosity depletion -- http://mail.python.org/mailman/listinfo/python-list

Re: My python annoyances so far

2007-04-27 Thread Bjoern Schliessmann
Steven D'Aprano wrote: > Perhaps you should read about the Kingdom of Nouns: > > execution-in-kingdom-of-nouns.html> Really cool. :) Thanks for sharing the link. Regards, Björn -- BOFH excuse #118: the router thinks its a printer. -- http://mai

Re: My python annoyances so far

2007-04-27 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > Well, I'd use ruby but python is everywhere, and ruby isn't. All > the applications that interest me are scriptable in python, not > ruby. Pity that you don't comment core topics. Regards, Björn -- BOFH excuse #289: Interference between the keyboard and the chair.

Re: Memory addressing

2007-04-27 Thread Bjoern Schliessmann
Simon Berube wrote: > When you call certain objects __repr__() strings in python you > often get the : happen. I am simply > trying to understand how that information can be used to recreate > a certain object that failed as per the given purpose of the > __repr__() functions. It cannot. The str

Re: My newbie annoyances so far

2007-04-27 Thread Bjoern Schliessmann
Dennis Lee Bieber wrote: > And I'll probably ignore those expressions whenever I do get > around to 2.5+... That syntax, in my mind, just... stinks... > > HP RPL made more sense: b if c [else d] end Please explain. HP RPL: b if c [else d] end Python: b if c else d What's the "more sense" here?

Re: if __name__ == 'main': & passing an arg to a class object

2007-04-28 Thread Bjoern Schliessmann
alisonken1 wrote: [if __name__ == "__main__"] > These are samples to give the programmer an idea of how the code > is supposed to work. No, this belongs into comments or docs. The contents of this block are often used for testing or debugging, or for normally executable code if it makes sense to

Re: My newbie annoyances so far

2007-04-28 Thread Bjoern Schliessmann
Dennis Lee Bieber wrote: > You didn't take account of what b, c, and d were... > > RPL: if else end > Python:if else > > (RPL is a somewhat common reference to the stack based language of > the later calculators -- HP48, for instance) I still don't see the "more se

Re: Beginner Ping program

2007-04-29 Thread Bjoern Schliessmann
Linus Cohen wrote: > Actually the class ping bit is a placeholder. But why is it one? "ping" is something you do -- and not a "thing" of which you could have several copies. > I'm actually developing a module with python implementations of > most standard network/internet tools such as telnet,

Re: My newbie annoyances so far

2007-04-29 Thread Bjoern Schliessmann
Steven D'Aprano wrote: > There are bad programmers in every language, but RPL conditional > blocks aren't the cause of them. Once you learn how RPL works, if > statements work consistently and obviously (although maybe not to > programmers who don't get RP notation). ACK. What made me anwswer was

Simulating simple electric circuits

2007-05-07 Thread Bjoern Schliessmann
Hello all, I'm trying to simulate simple electric logic (asynchronous) circuits. By "simple" I mean that I only want to know if I have "current" or "no current" (it's quite digital) and the only elements need to be (with some level of abstraction to my specific problem) - sources (here begin curr

Re: Simulating simple electric circuits

2007-05-07 Thread Bjoern Schliessmann
Arnaud Delobelle wrote: > On May 7, 7:05 pm, Bjoern Schliessmann > There is a master "current controller" object which tells >> the "source" object to start a "current" by calling its >> neighbour. The calls traverse the network until they reac

Re: Simulating simple electric circuits

2007-05-09 Thread Bjoern Schliessmann
Stef Mientki wrote: > Bjoern Schliessmann wrote: >> - sources (here begin currents) >> - ground (here end currents) > that doesn't bring you anywhere ;-) It does :) > Current doesn't start or end at some location, > current flows through a closed circuit. The

Re: Simulating simple electric circuits

2007-05-09 Thread Bjoern Schliessmann
Dave Baum wrote: > Are you trying to do logic simulation (digital) or analog circuit > simulation? Mh, a mix of both :) I want to simulate (in principle simple) magnetic relay circuits. The only "evil tricks" that are used are - shortcuts (e. g. a relay coil is bypassed and thus the relay gets

Re: Simulating simple electric circuits

2007-05-09 Thread Bjoern Schliessmann
Arnaud Delobelle wrote: > When you turn a switch off, it would send a message to the paths > that depend on it (maybe via the controller?) so that they would > be > deactivated. In turn the lightbulbs on these paths would be > informed that they are no longer active. > > When you turn a switch o

Re: Newbie prob: How to write a file with 3 threads?

2007-05-09 Thread Bjoern Schliessmann
est wrote: > I'd like to say VERY VERY VERY thank you for your detailed > information, that's a lot encourage for a beginner. In fact I am > writing a multi thread download ultility, and I found that very > hard for me. You don't need any system threads for multiple download threads. Since netwo

Re: Inheritance problem

2007-05-09 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > class longList(shortList): > > def __init__(self): > > shortList.setList() > > self.setList() Addition: Always call the base class __init__ in your constructor if there exists one, i. e. class longList(shortList) def __init__(self): s

Re: Simulating simple electric circuits

2007-05-11 Thread Bjoern Schliessmann
Dave Baum wrote: > Sounds reasonable. Depending on the size of your network, I might > not worry too much about precomputing and saving information. Thanks. Yes, I'm actually testing it presently without any optimizations and it runs very well. > If your circuit has loops in it (where the ou

Re: [Newbie] design question

2007-05-12 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > Suppose I have class ShoppingCart which has one method called > buy(), and class Buyer who has one reference to ShoppingCart... > Can I also have method buy() in class Buyer, which will then > called ShoppingCard.buy(), and also do some other stuff? Is this > legal desi

Re: Simulating simple electric circuits

2007-05-13 Thread Bjoern Schliessmann
Arnaud Delobelle wrote: > I'm interested! I was tempted to have a go at it after your > initial post, it sounded like a nice little project :) Please stand by a day. I'm momentarily facing problems with currents that never end (going in a circle). And my code doesn't look that beatiful and/or clea

Re: Asyncore Help?

2007-05-14 Thread Bjoern Schliessmann
Nick Craig-Wood wrote: > http://twistedmatrix.com/trac/ > > The learning curve of twisted is rather brutal, NACK, the tutorial is -- IMHO -- rather easy if you are used to writing Python code and doing asynchronous programming.

Re: Simulating simple electric circuits

2007-05-14 Thread Bjoern Schliessmann
Arnaud Delobelle wrote: > I'm interested! I was tempted to have a go at it after your > initial post, it sounded like a nice little project :) Here you go, see below (quite long). It works from Python 2.5 and above and should be straightly executable from command line. (It'll work with lower Pyt

Re: Simulating simple electric circuits

2007-05-15 Thread Bjoern Schliessmann
Bjoern Schliessmann wrote: > class Source(object): Little bug: The __init__ method of class Source should look like this. def __init__(self, ID, neighbour = None): self.connections = [] self.ID = ID if neighbour: self.connections.append(neighbour) Regards, Björn -- BOFH exc

Re: Simulating simple electric circuits

2007-05-15 Thread Bjoern Schliessmann
Bjoern Schliessmann wrote: > I suspect that this is a dead end though, because in more complex > designs the creation of circuits becomes cumbersome. Also, for the > system I want to model, the circuits are OOH very complex and OTOH > I don't have access to all circuit diagra

Re: PEP 3131: Supporting Non-ASCII Identifiers

2007-05-17 Thread Bjoern Schliessmann
"Martin v. Löwis" wrote: > I can't admit that, but I find that using German > class and method names is beautiful. The rest around > it (keywords and names from the standard library) > are not English - they are Python. > > (look me in the eye and tell me that "def" is > an English word, or that "

Re: questions about programming styles

2007-05-20 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > Hi all, I'm not skilled at programming, so sorry for my ignorance. ?! Seems you met many not-so-nice programmers. > (1) > which is the better way to calculate the value of attributes of a > class ? for example: > > (A) > def cal_attr(self, args): > #do s

Re: From D

2007-07-24 Thread Bjoern Schliessmann
Stargaming wrote: > On Tue, 24 Jul 2007 03:19:53 -0700, bearophileHUGS wrote: >> While in a syntax like: >> for i in xrange(1_000_000): >> my eyes help me group them at once. > > Sounds like a good thing to be but the arbitrary positioning > doesnt make any sense. Checking underscore positions

Re: first, second, etc line of text file

2007-07-25 Thread Bjoern Schliessmann
Grant Edwards wrote: > On 2007-07-25, Jeff McNeil <[EMAIL PROTECTED]> wrote: >> Depending on the size of your file, you can just use >> file.readlines. Note that file.readlines is going to read the >> entire file into memory, so don't use it on your plain-text >> version of War and Peace. > > I

Re: Filtering content of a text file

2007-07-27 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > I'd greatly appreciate if you can take a look at the task I need > help with. > > It'd be outstanding if someone can provide some sample Python > code. Sure. > CP: An inch of time is an inch of gold but you can't buy that inch > of time with an inch of gold. So, how

Re: Creating a shared object in python

2007-07-31 Thread Bjoern Schliessmann
Delgado, Edgardo CIV NAVAIR 4.1.4.3 wrote: > Is there a way to create a shared object in python? What's a shared object? Do you mean IPC or .so libraries, or something different? Regards, Björn -- BOFH excuse #404: Sysadmin accidentally destroyed pager with a large hammer. -- http://mail

Re: Extending Python by Adding Keywords & Data types

2007-08-01 Thread Bjoern Schliessmann
Maximus Decimus wrote: > Since, I am an amateur in using python, | Most commonly an amateur is understood to be someone who does | something without pay or formal training. Conversely, a | professional is someone who has received training in a particular |

Re: wxPython version question

2007-08-01 Thread Bjoern Schliessmann
The Max wrote: > Hi have need of testing the version of wxPython in use at the > moment I use wxversion, but I don't can find a method for testing > version like this: > > if versionOfWX() <= 2.8: > > or > > if versionOfWX() >= 2.8: > > ( versioneOfWX is a pseudo-function create for this

Re: Representation of new-style instance

2007-08-02 Thread Bjoern Schliessmann
Raj B wrote: > Which C struct in the Python implementation is used to represent > the instances c1 and c2 of the new-style class? You don't try to send this raw over some stream connection, do you? Regards, Björn -- BOFH excuse #349: Stray Alpha Particles from memory packaging caused Hard

Re: Seek the one billionth line in a file containing 3 billion lines.

2007-08-08 Thread Bjoern Schliessmann
Peter Otten wrote: > n = 10**9 - 1 > assert n < sys.maxint > f = open(filename) > wanted_line = itertools.islice(f, n, None).next() > > should do slightly better than your implementation. It will do vastly better, at least in memory usage terms, because there is no memory eating range call. Reg

Re: Help with Dictionaries and Classes requested please.

2007-08-09 Thread Bjoern Schliessmann
special_dragonfly wrote: > I've managed to solve the problem, I really was just being a > dunce. Here's how incase anyone is wondering: > > class MyClass: > def __init__(self): > name="" > dict={} > dict[0]=[] > dict[0].append(MyClass()) > dict[0][0].name="Hello" > print dict[0][0].na

<    1   2   3   4   5   6   >