Referring to Interpreter (Jython)

2006-07-23 Thread wojciech
there is the "this" keyword which allows an object to refer to itself. Does anyone know if there is a way to use a similar type of keyword to have the PythonInterpreter refer to itself? Thanks, Wojciech P.S. If there is a more appropriate newsgroup to which I should post this, please l

Re: Referring to Interpreter (Jython)

2006-07-23 Thread wojciech
Hi everyone, Ah, after some more searching and programming, I got it: PythonInterpreter py = new PythonInterpreter(); py.set("interpreter", py); Thanks, Wojciech [EMAIL PROTECTED] wrote: > Hi everyone, > > I apologize if this is a bit off-topic. I am currently workin

Re: Lots of pdf files

2005-07-20 Thread Wojciech Mula
Greg Lindstrom wrote: > There does not appear to be a simple way to merge many pdf's into one. Program pdftk can merge pdf's, but I have never tried it. You may also use pdflatex --- there is a package called pdfpages provides powerful command \includepdf. w. -- http://mail.python.org/mailman/

Re: Suggestions for optimizing my code

2005-08-05 Thread Wojciech Mula
drife wrote: > [...] > for row in range(len(Y)): > for col in range(0,row): In this case you should use 'xrange' instead 'range'. w. -- http://mail.python.org/mailman/listinfo/python-list

Re: is there a better way to check an array?

2005-09-01 Thread Wojciech Mula
jdonnell wrote: > I want to check if a value is in an array. I'm currently doing it as > follows, but I just don't like this way of doing it. It seems > unpythonic. > > fieldIsRequired = true > try: > notRequiredAry.index(k) > fieldIsRequired = false > except ValueError: > pass > > #

Re: SSH/Telnet program to Router/switch

2014-02-19 Thread Wojciech Łysiak
On 19.02.2014 09:14, Sujith S wrote: > Hi, > > I am new to programming and python. I am looking for a python script to do > ssh/telnet to a network equipment ? I know tcl/perl does this using > expect/send. > > Do we have expect available in python as well or need to use some other > method ?

Re: Confused with Functions and decorators

2014-07-19 Thread Wojciech Giel
On 19/07/14 11:52, Jerry lu wrote: Ok so i am trying to learn this and i do not understand some of it. I also tried to searched the web but i couldnt find any answers. 1. I dont understand when i will need to use a function that returns another function. eg def outer():

Re: Confused with Functions and decorators

2014-07-19 Thread Wojciech Giel
mat(x)) ... return x ... >>> h = outer(f, g) >>> h("test") g (test) called f (test) called 'test' cheers Wojciech -- https://mail.python.org/mailman/listinfo/python-list

Re: Confused with Functions and decorators

2014-07-19 Thread Wojciech Giel
r function") ... return f(*args, **kwargs) ... return inner ... >>> def myfunc(x): ... print("Myfunc", x) ... >>> myfunc = outer(myfunc) >>> myfunc("test") inner function Myfunc test cheers Wojciech and also with the first example

Re: What's the proper style for a library string function?

2014-07-19 Thread Wojciech Giel
getCompletedTime(start, end): return "Time completed:", str(end - start) if you need to print just add print, if you want result from this function somewhere else you got it. adding additional arguments necessary adds complexity. do you really need it. Keep it simple stupid expression can be applied everywhere. cheers Wojciech -- https://mail.python.org/mailman/listinfo/python-list

Re: Pythonic way to iterate through multidimensional space?

2014-08-06 Thread Wojciech Giel
[[[54, 55, 56], [57, 58, 59], [60, 61, 62]], [[63, 64, 65], [66, 67, 68], [69, 70, 71]], [[72, 73, 74], [75, 76, 77], [78, 79, 80) >>> f = a.flat >>> for i in f: ...print(i) 0 1 2 .. 98 99 cheers

Re: double underscore attributes?

2005-12-10 Thread Wojciech Mula
[EMAIL PROTECTED] wrote: > Now I went to Python Library Reference and searched for "__add__" but > got zero hits. http://python.org/doc/2.4.2/ref/specialnames.html -- http://mail.python.org/mailman/listinfo/python-list

Python Data Explorer

2006-07-16 Thread Wojciech Morański
Does anybody know some GUI (preferably QT) application which can be use to explore pickled python objects? Similar functionality has a PyDev Debugger in Eclipse, but I would like to have a standalone application. I know that it is not hard to write it, but I don't want to again invent a wheel ;o)

Re: create global variables?

2006-10-30 Thread Wojciech Muła
Alistair King wrote: > is there a simple way of creating global variables within a function? def foo(name): globals()[name] = "xxx" globals()[name + 'aa'] = "yyy" globals()[name + 'ab'] = "zzz" -- http://mail.python.org/mailman/listinfo/python-list

Re: string formatter for tuple

2006-11-02 Thread Wojciech Muła
Tim Chase wrote: > print "a = %s" % repr(a) or print "a = %r" % (a,) -- http://mail.python.org/mailman/listinfo/python-list

Re: How to choose the right GUI toolkit ?

2006-11-09 Thread Wojciech Muła
Nick Craig-Wood wrote: >> It's very mature, full-featured, and portable, and fairly easy to >> learn as well. > > ...with native look and feel on each platform unlike GTK / TK AFAIK Tk 8 uses platform's native widgets. w. -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter: Strange behavior using place() and changing cursors

2006-11-14 Thread Wojciech Muła
Mudcat wrote: > [...] You have to set cursor once, Tk change it automatically: > def buildFrame(self): > self.f = Frame(self.master, height=32, width=32, relief=RIDGE, > borderwidth=2) > self.f.place(relx=.5,rely=.5) #self.f.bind( '', self.enterFr

Re: Tkinter: Strange behavior using place() and changing cursors

2006-11-14 Thread Wojciech Muła
Mudcat wrote: > I have also determined that this is not a problem if the button is not > packed inside the frame. So somehow the interaction of the internal > button is causing this problem. Problem is really strange, and seems to be a Tk issue, not Tkinter. I've observed that if method configure

Re: math.pow(x,y)

2006-06-11 Thread Wojciech Muła
fl1p-fl0p wrote: > import math > math.pow(34564323, 456356) > > will give math range error. > > how can i force python to process huge integers without math range > error? Any modules i can use possibly? You have to use operator **, i.e. 34564323**456356 -- http://mail.python.org/mailman/listinfo

Re: Negative hex to int

2006-06-14 Thread Wojciech Muła
[EMAIL PROTECTED] wrote: > The problem is negative values. If the unit returns the hex value 'e7', > it means -25, but python says it's 231: > --- int('e7', 16) > 231 > --- > > Does anyone have a clue a to what I need to do? def u2(x): i

Re: length of multidimensional table

2006-12-17 Thread Wojciech Muła
vertigo wrote: > i have: > x = zeros([3,4],Float) > > how can i check how many rows and columns x have ? > (what is the X and Y size of that table) ? Data member x.shape (tuple) contains dimensions of array. -- http://mail.python.org/mailman/listinfo/python-list

Re: Fuzzy string comparison

2006-12-26 Thread Wojciech Muła
Steve Bergman wrote: > I'm looking for a module to do fuzzy comparison of strings. [...] Check module difflib, it returns difference between two sequences. -- http://mail.python.org/mailman/listinfo/python-list

Re: Change coords of a canvas.line item

2007-01-05 Thread Wojciech Muła
Fredrik Lundh wrote: > Matthias Vodel wrote: > >> I want to change the beginning/end-coordinates of a canvas.line item. >> >> Something like: >> >> self.myCanvas.itemconfigure(item_id, coords=(x1_new, y1_new, x2_new, y2_new)) > > self.myCanvas.coords(item_id, x1_new, y1_new, x2_new, y2_new) Yo

Re: More Efficient fnmatch.fnmatch for multiple patterns?

2007-01-08 Thread Wojciech Muła
abcd wrote: > I am using fnmatch.fnmatch to find some files. The only problem I have > is that it only takes one pattern...so if I want to search using > multiple patterns I have to do something like > > patterns = ['abc*.txt', 'foo*'] > > for p in patterns: > if fnmatch.fnmatch(some_file

restricted mode (2.4.2)

2006-02-17 Thread Wojciech Pawlikowski
stricted mode Is there any way to avoid this mode ? -- ___ * Wojciech Pawlikowski :: :: GG: 4155781 * * http://www.knockdownhc.com || http://www.kingofthehillhc.com * * "Loved by a few, Hated by many, But respected by ALL" * -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter toggle a Label Widget based on checkbutton value

2007-07-04 Thread Wojciech Muła
O.R.Senthil Kumaran wrote: > Any suggestions on how can i make this checkbutton effect. > 1) Press Enable IP, the Label IP should be shown. > 2) Toggle Enable IP (So that its unset). the Label IP should not be shown. > > #!/usr/bin/python > from Tkinter import * > root = Tk() > root.title('somethi

Re: atexit, sys.exit, sys.exitfunc, reaching end of source code

2007-07-11 Thread Wojciech Muła
[EMAIL PROTECTED] wrote: > I am playing with the atexit module but I don't find a way to see the > difference > between a script calling sys.exit() and the interpreting > arriving at the end > of the source code file. This has a semantic difference for my > applications. > Is there a way to determi

Re: Itertools question: how to call a function n times?

2007-07-19 Thread Wojciech Muła
Matthew Wilson wrote: > I want to write a function that each time it gets called, it returns a > random choice of 1 to 5 words from a list of words. > > I can write this easily using for loops and random.choice(wordlist) and > random.randint(1, 5). > > But I want to know how to do this using iterto

Re: regular expression for parsing an html element

2007-04-20 Thread Wojciech Muła
abcd wrote: > My regex so far is: src=\"(.*)\" however the group in this case > would end up being, image/blah/a.jpg" id="d">blah blah blah a>. > > how can I tell the regex group (.*) to end when it gets to the first > " ? Use non-greedy matching, i.e. src=\"(.*?)\" (question mark af

Re: tkinter paint program

2007-04-24 Thread Wojciech Muła
Gigs_ wrote: > I'm working on tkinter paint program, mostly to learn tkinter canvas. > I have method which create buttons for oval, rectangle, line, polygon etc. > How to make oval button to be sunken when i click it and to remain > sunken until i click on another button (like rectangle and than i

Re: custom plugin architecture: how to see parent namespace?

2007-07-22 Thread Wojciech Muła
escalation746 wrote: > def ViewValuable(): [...] > code = """ > Hello() > Plus() > Valuable() > """ These names don't match. I replaced Valuable() with proper name, and everything work fine. w. -- http://mail.python.org/mailman/listinfo/python-list

Re: split a string of space separated substrings - elegant solution?

2007-07-31 Thread Wojciech Muła
Helmut Jarausch wrote: > Hi, > > I'm looking for an elegant solution to the following (quite common) > problem: > > Given a string of substrings separated by white space, > split this into tuple/list of elements. > The problem are quoted substrings like > > abc "xy z" "1 2 3" "a \" x" > > should

Re: Memory Leak with Tkinter Canvas (Python 2.5 Win32)

2007-08-02 Thread Wojciech Muła
frikk wrote: > [...] > As you can see- I am doing nothing other than drawing a lot of > rectangles on the canvas. You aren't drawing, but **creating** rectangle objects, as a meth. name suggests. You find more info at tkinter.effbot.org. > [...] > > def clear_grid(): canv.delete(ALL)

Re: interpreting glyph outlines from ttfquery?

2007-03-22 Thread Wojciech Muła
swiftset wrote: > I'm try to convert a glyph into a format I can easily numerically > manipulate. So far I've figured out how to use ttfquery to get a list > that represents the outline of a contour in a glyph: > > from ttfquery import describe, glyphquery, glyph > f = describe.openFont("/usr/shar

Re: call to function by text variable

2007-03-25 Thread Wojciech Muła
ianaré wrote: > like this: > > > list = ["Replace", "ChangeCase", "Move"] > textVariable = list[n] > self.operations.insert(pos, operations.[textVariable].Panel(self, > main)) > > Is something sort of like that possible? Yes: self.operations.insert( pos, getattr(operations, tex

Re: XML minidom Parsing and ToPrettyXML

2007-03-25 Thread Wojciech Muła
Paul Kozik wrote: > However, if I use xml.minidom.parse to parse the xml document, change > a few attributes with setAttribute, then write back with toprettyxml, > my XML file gets loaded up with spaces between many of the elements. Use 'toxml' method, that writes XML document without any modifica

Re: pattern search

2007-03-27 Thread Wojciech Muła
Fabian Braennstroem wrote: > Now, I would like to improve it by searching for different 'real' > patterns just like using 'ls' in bash. E.g. the entry > 'car*.pdf' should select all pdf files with a beginning 'car'. > Does anyone have an idea, how to do it? Use module glob. -- http://mail.python.

Re: Cascading ifs

2007-04-02 Thread Wojciech Muła
Ernesto García García wrote: > Hi experts, > > How would you do this without the more and more indenting cascade of ifs?: > > match = my_regex.search(line) > if match: > doSomething(line) > else: > match = my_regex2.search(line) > if match: > doSomething2(line) > else: > match = m

Re: 08 and 09 in sequence create "invalid token" error?!

2007-04-06 Thread Wojciech Muła
IamIan wrote: > I am confused as to why including 08 or 09 in a sequence (list or > tuple) causes this error. All other numbers with a leading zero work. All literals that start with "0" digit are considered as octal numbers, i.e. only digits "0".."7" are allowed. See octinteger lexical definitio

Re: Saving output of Turtle Graphics?

2007-04-07 Thread Wojciech Muła
Dick Moores wrote: > I accidentally stumbled across the Turtle Graphics module (turtle.py) > the other day and have been having some fun with it. > > Now I'm wondering if there is a way to build into a script the saving of > each window just before it is cleared. For example, here are a couple

Re: Checking whether list element exists

2007-04-07 Thread Wojciech Muła
Rehceb Rotkiv wrote: > I want to check whether, for example, the element myList[-3] exists. So > far I did it like this: > > index = -3 > if len(myList) >= abs(index): > print myList[index] IMHO it is good way. > Another idea I had was to (ab-?)use the try...except structure: > > index =

Re: Saving output of Turtle Graphics?

2007-04-07 Thread Wojciech Muła
Dick Moores wrote: >> Turtle module uses Tk canvas element to draw graphics ('_canvas' >> attribute). I've written module, that exports canvas graphics to SVG >> file: http://wmula.republika.pl/proj/canvas2svg/ -- it may be useful >> for you. > > I afraid I'm totally unfamiliar with SVG. Would it

Re: Saving output of Turtle Graphics?

2007-04-07 Thread Wojciech Muła
Dick Moores wrote: > What do I do to see this? For example Opera 9 and Firefox 1.5+ are able to view SVG files; there is a free plugin for IrfanView. w. -- http://mail.python.org/mailman/listinfo/python-list

Re: list comparison help?

2007-04-14 Thread Wojciech Muła
Dropkick Punt wrote: prefixes = [ "the", "this", "that", "da", "d", "is", "are", "r", "you", "u"] > > And I have a string, that I split() into a list. > sentence = "what the blazes is this" sentence = sentence.split() > > Now I want to strip the sentence of all words in the

Python "implements " equivalent?

2007-10-04 Thread Wojciech Gryc
cifically, a general class / interface called "Feature" and then subclasses that implement functions like isFeaturePresent() in all of their different and unique ways. I'd love to hear how I can do this in Python. Thanks, Wojciech -- http://mail.python.org/mailman/listinfo/python-list

Re: Python "implements " equivalent?

2007-10-04 Thread Wojciech Gryc
Thank you Carl and thank you Jarek. This makes me feel much better -- on to coding, I shall go. :) Thanks again, Wojciech On Oct 4, 11:27 am, Carl Banks <[EMAIL PROTECTED]> wrote: > On Oct 4, 11:11 am, Wojciech Gryc <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I

Re: Trouble with max() and __cmp__()

2007-01-28 Thread Wojciech Muła
Thomas Nelson wrote: > My code: > > class Policy(list): > def __cmp__(self,other): > return cmp(self.fitness,other.fitness) Define method __gt__. -- http://mail.python.org/mailman/listinfo/python-list

Re: Conversion of string to integer

2007-01-29 Thread Wojciech Muła
jupiter wrote: > I have a problem. I have a list which contains strings and numeric. > What I want is to compare them in loop, ignore string and create > another list of numeric values. > > I tried int() and decimal() but without success. > > eq of problem is > > #hs=string.split(hs) > hs =["popo

Re: Vim search under cursor

2007-02-07 Thread Wojciech Muła
[EMAIL PROTECTED] wrote: > Hi, I am using gvim to edit python source files. When I press "*" or > "#", I would want to search for the attribute name under the cursor > and not the entire string. > For example, If I have os.error and pressing * on top of error > searches for os.error rather than er

readlines() reading incorrect number of lines?

2007-12-20 Thread Wojciech Gryc
uld be grateful for any advice as to what I'm doing wrong, or why this may be happening. Thank you, Wojciech Gryc -- http://mail.python.org/mailman/listinfo/python-list

Re: readlines() reading incorrect number of lines?

2007-12-20 Thread Wojciech Gryc
;t see the rest of the file, I don't even know how to get to it to fix the problem... Due to the nature of the data I'm working with, manual editing is also not an option. Thanks, Wojciech On Dec 20, 3:30 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Dec 21, 6:48 am, Wojciech G

Re: list example

2006-04-22 Thread Wojciech Muła
PAolo wrote: > any comment, suggestion? Is there something not elegant? Try this: even = range(10)[0::2] odd = range(10)[1::2] -- http://mail.python.org/mailman/listinfo/python-list

Re: index in for loops

2006-05-17 Thread Wojciech Muła
manstey wrote: > in for loops like the following: > > word='abcade' > > for letter in word: >print letter > > > Is it possible to get the position of letter for any iteration through > the loop? for index, letter in enumerate(word): print index, letter -- http://mail.python.org/mailma

Re: Sorting of list containing tuples

2006-05-18 Thread Wojciech Muła
Ronny Mandal wrote: > Assume we have a list l, containing tuples t1,t2... > > i.e. l = [(2,3),(3,2),(6,5)] > > And now I want to sort l reverse by the second element in the tuple, > i.e the result should ideally be: > > l = [(6,5),(2,3),(3,2)] > > > Any ideas of how to accomplish this? def cmpfun

Re: [OT] stable algorithm with complexity O(n)

2008-12-13 Thread Wojciech Muła
"David Hláčik" wrote: > I have to create stable algorithm for sorting n numbers from interval > [1,n^2] with time complexity O(n) . Some kind of radix sort or counting sort. These algo. has O(n) complexity. w. -- http://mail.python.org/mailman/listinfo/python-list

Re: 1 or 1/0 doesn't raise an exception

2008-12-13 Thread Wojciech Muła
"Daniel Fetchinson" wrote: > Is it a feature that > > 1 or 1/0 > > returns 1 and doesn't raise a ZeroDivisionError? If so, what's the rationale? See: http://en.wikipedia.org/wiki/Short-circuit_evaluation -- http://mail.python.org/mailman/listinfo/python-list

Re: Determine socket family at runtime

2008-05-04 Thread Wojciech Walczak
2008/5/4, Giampaolo Rodola' <[EMAIL PROTECTED]>: > For now I've been able to determine the family by using: > > # self.socket = a connected socket.socket instance > ip, port = self.socket.getsockname()[0:2] > af = socket.getaddrinfo(ip, port)[0][0] > > ...but I'd like to know if some other sol

Re: confused about self, why not a reserved word?

2008-05-05 Thread Wojciech Walczak
2008/5/5, globalrev <[EMAIL PROTECTED]>: > class Foo(object): > def Hello(self): > print "hi" > > object is purple, ie some sort of reserved word. > > why is self in black(ie a normal word) when it has special powers. > replacing it with sel for example will cause an erro

Re: pygame music, cant read mp3?

2008-05-05 Thread Wojciech Walczak
2008/5/5, globalrev <[EMAIL PROTECTED]>: > pygame.mixer.music.load('C:/Python25/myPrograms/pygameProgs/example1.mp3') Are you sure that: os.path.exists('C:/Python25/myPrograms/pygameProgs/example1.mp3') == True? Check it with python. -- Regards, Wojtek Walczak http://www.stud.umk.pl/~wojtekwa

Re: Decimal vs Float comparasion

2008-05-05 Thread Wojciech Walczak
2008/5/6, Yuan HOng <[EMAIL PROTECTED]>: > It seems decimal object will always be larger than float in > comparasion, which goes against common sense: > > >>> from decimal import Decimal > >>> a = Decimal('0.5') > >>> a > 9 > False > >>> a > 9.0 > True > > It seems to me that rathe

Re: Decimal vs Float comparasion

2008-05-05 Thread Wojciech Walczak
2008/5/6, Wojciech Walczak <[EMAIL PROTECTED]>: > a > 9.0 returns True because NotImplemented > 9.0 returns True. > a < 9.0 returns False because NotImplemented < 9.0 returns False. Sorry, it should rather be: Decimal('0.5') > 9

Re: #!/usr/bin/env python vs. #!/usr/bin/python

2008-05-06 Thread Wojciech Walczak
2008/5/6, Banibrata Dutta <[EMAIL PROTECTED]>: > > Use /usr/bin/env. If env is not in /usr/bin, put a link to it there. > > So why not put symlink to Python over there on all machines, if we can > put one (or env itself) there ? To avoid linking all the rest of interpreters like perl, ruby, lu

Re: #!/usr/bin/env python vs. #!/usr/bin/python

2008-05-06 Thread Wojciech Walczak
2008/5/6, Ben Finney <[EMAIL PROTECTED]>: > > > So why not put symlink to Python over there on all machines, if > > > we can put one (or env itself) there ? > > To avoid linking all the rest of interpreters like perl, ruby, lua > > and dozens of others. > The argument was being made from "thou

Re: python vs. grep

2008-05-06 Thread Wojciech Walczak
2008/5/6, Anton Slesarev <[EMAIL PROTECTED]>: > But I have some problem with writing performance grep analog. [...] > Python code 3-4 times slower on windows. And as I remember on linux > the same situation... > > Buffering in open even increase time. > > Is it possible to increase file readin

Re: assert type([]) == type(())

2010-01-02 Thread Wojciech Muła
VanceE wrote: > for x in []: > assert type(x) == type(()) > > I expected an AssertionError but get no errors at all. > Any explaination? [] is an empty sequence, so your loop executes exactly 0 times. :) for x in [None]: assert ... w. -- http://mail.python.org/mailman/listinfo/py

Re: use strings to call functions

2010-02-08 Thread Wojciech Muła
Klaus Neuner wrote: > > handlers = { > >     ".txt" : handle_txt, > >     ".py" : handle_py, > >     # etc > >     } > > > > That is exactly what I would like to avoid: Having to map the function > 'handle_txt' to '.txt'. Firstly, because I don't want to repeat > anything and secondly, because I

Re: interleave string

2011-02-15 Thread Wojciech Muła
On Tue, 15 Feb 2011 10:53:56 +0100 Andrea Crotti wrote: > Just a curiosity not a real problem, I want to pass from a string like > > xxaabbddee > to > xx:aa:bb:dd:ee > > so every two characters insert a ":". > At the moment I have this ugly inliner > interleaved = ':'.join(orig[x:x+2] f

How to know if connection is active when using telnetlib?

2005-08-26 Thread Wojciech Halicki-Piszko
How to know if connection is active after telnetlib.Telnet.open(host,port)? -- http://mail.python.org/mailman/listinfo/python-list

Re: How to know if connection is active when using telnetlib?

2005-08-26 Thread Wojciech Halicki-Piszko
> If open() doesn't throw an exception then you should have a connection you can > start reading/writing with. Unless you have some special meaning for > 'active'? > > I'm just basing this on reading telnetlib.py. > > Eddie Well, in fact what I meant is: I won't to check wether established conn