Re: Book "Python and Tkinter Programming"
It is available as PDF from the editor ... Manning. In my recollection for 25 USD projecktzero wrote: > striker wrote: > >>Does anyone who has this book willing to sell it. Please e-mail me the >>condition and any other details if you are interested. >>Thanks, >>Kevin > > > half.com has a couple of people selling it. One for $35.24 and another > for $129.97. > -- http://mail.python.org/mailman/listinfo/python-list
Re: Obtaining an member function by name
guy lateur wrote: > Hi all, > > Suppose you have this class: > > class foo: > def bar(): > > Suppose you also have the strings "foo" and "bar". How can you obtain the > function foo.bar()? > > Surely somebody knows.. > > TIA, > g > > Would that do? >>> class foo: @staticmethod def bar(): pass >>> foo.bar >>> -- http://mail.python.org/mailman/listinfo/python-list
Re: An mysql-python tutorial?
Dfenestr8 wrote: Hi. Been told by the admin of my (free!) server that he'd rather I should learn to use mysql if I want to continue writing cgi scripts there. Not even sure exactly what mysql is. Is there a simple tutorial anywhere on the web about using python + mysql? http://www.devshed.com/c/a/Python/MySQL-Connectivity-With-Python/ that one put me on the right track (I think ;) -- EuGeNe [ www.boardkulture.com www.actiphot.com www.xsbar.com ] -- http://mail.python.org/mailman/listinfo/python-list
bicyclerepairman python24 windows idle :(
Hi there, I am no expert but wanted to give bicyclerepairman 0.9 a go just to see what a refactoring browser is and does. Followed every step of the install, I think, but idle doesn't start with the RepairMan section in config-extensions.def ... is it incompatible with 2.4? Thanks for your help. -- EuGeNe [ www.boardkulture.com www.actiphot.com www.xsbar.com ] -- http://mail.python.org/mailman/listinfo/python-list
Re: bicyclerepairman python24 windows idle :(
Kim Changjune wrote: EuGeNe wrote: Hi there, I am no expert but wanted to give bicyclerepairman 0.9 a go just to see what a refactoring browser is and does. Followed every step of the install, I think, but idle doesn't start with the RepairMan section in config-extensions.def ... is it incompatible with 2.4? Thanks for your help. -- EuGeNe There seems to be a change in idlelib in Python 2.4. Apply following patch to BicycleRepairMan_Idle.py: @@ -87,6 +87,7 @@ mbar = editwin.menubar editwin.menudict[name] = menu = Menu(mbar, name = name) mbar.add_cascade(label = label, menu = menu, underline = underline) +self.editwin.fill_menus(self.menudefs) # Initialize Bicyclerepairman and import the code path = self.editwin.io.filename thanks for the tip ... unfortunately it doesn't work either. IDLE doesn't start. -- EuGeNe [ www.boardkulture.com www.actiphot.com www.xsbar.com ] -- http://mail.python.org/mailman/listinfo/python-list
Re: bicyclerepairman python24 windows idle :(
Kim Changjune wrote: EuGeNe wrote: Hi there, I am no expert but wanted to give bicyclerepairman 0.9 a go just to see what a refactoring browser is and does. Followed every step of the install, I think, but idle doesn't start with the RepairMan section in config-extensions.def ... is it incompatible with 2.4? Thanks for your help. -- EuGeNe There seems to be a change in idlelib in Python 2.4. Apply following patch to BicycleRepairMan_Idle.py: @@ -87,6 +87,7 @@ mbar = editwin.menubar editwin.menudict[name] = menu = Menu(mbar, name = name) mbar.add_cascade(label = label, menu = menu, underline = underline) +self.editwin.fill_menus(self.menudefs) # Initialize Bicyclerepairman and import the code path = self.editwin.io.filename sorry but it didn't make any difference ... idle doens't start :( -- EuGeNe [ www.boardkulture.com www.actiphot.com www.xsbar.com ] -- http://mail.python.org/mailman/listinfo/python-list
Grayson's Tkinter Programming
Just noticed that it is now availabe as an ebook from Manning : http://www.manning.com/books/grayson I bought an edition on abebooks for a little fortune a few months ago ... -- http://mail.python.org/mailman/listinfo/python-list
Re: Any affordable Python-based CRM & ERP solutions?
Will wrote: Hi all, Please excuse the longish post. I'm new to Python (and programming), but love what I see and believe it to be an important language. I have (at least) one retail client (with single outlet at present) that requires a total business solution for their operation, preferably open source. They need: - an ecommerce website providing sales, customer service, order tracking and an opt-in newsletter - system for tracking inventory - full accounting system, tied-into the ecommerce website-- so full front-end and back-end system integration - possibly even point of sale tied-into the above. They've been using Windows up until now, but are happy to consider Linux, BSD, Mac, etc, as long as there's not a huge learning curve (they merely want a solution that works and is cost-effective). Other than standard accounting reporting requirements, they need the ability to add tax to local transactions. I have Googled with not a lot of contenders (Compiere-- http://www.compiere.org/index.html -- not Python and an Oracle license is required to run it; and I've just started reading about Bizar Shop-- http://www.bizarshop.com.au/). Anything else I've seen is either really expensive, doesn't fit the bill, or are not Python-based (which I'd ultimately like to promote). Because of the above requirements I was thinking something quite modular (that could be added to in future) would be the way to go. I like what I have seen with Plone and Zope but am unsure at present (given limited experience with these products) how one would integrate something into those solutions (if package didn't come from one 'vendor'), so that at least on the surface, everything appeared pretty seamless. Is this wishful thinking in Python at present? If so, have you encountered any other open source solutions that cover part of the above with Python handling the rest (and being easily integrated)? I look forward to any feedback. Thanks very much in advance. Cheers, Will :) Maybe http://www.erp5.org/ is what you are looking for! -- http://mail.python.org/mailman/listinfo/python-list
Re: PyParsing module or HTMLParser
Lad wrote: I came across pyparsing module by Paul McGuire. It seems to be nice but I am not sure if it is the best for my need. I need to extract some text from html page. The text is in tables and a table can be inside another table. Is it better and easier to use the pyparsing module or HTMLparser? Thanks for suggestions. La. Check BeautifulSoup (http://www.crummy.com/software/BeautifulSoup/)it did the job for me! -- EuGeNe [ www.boardkulture.com www.actiphot.com www.xsbar.com ] -- http://mail.python.org/mailman/listinfo/python-list
Re: Python instances
[EMAIL PROTECTED] wrote: Hi, How do python instances work? Why does the code at the end of my posting produce this output: list in a: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] list in b: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] instead of list in a: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] list in b: [] class MyClass: list = [] def add(self, x): self.list.append(x) def printer(self): print self.list a = MyClass() b = MyClass() for n in range(10): a.add(n) print "list in a:" a.printer() print "list in b:" b.printer() /H because list is a class member not an instance member (not sure about the vocabulary) if in __init__ you set self.list=[] you'll get the result you want! By declaring list=[] in the class it is shared between all instances! -- EuGeNe [ www.boardkulture.com www.actiphot.com www.xsbar.com ] -- http://mail.python.org/mailman/listinfo/python-list
Re: Regex substitution trouble
massi_...@msn.com wrote: > Hi everyone, > > I'm not really sure if this is the right place to ask about regular > expressions, but since I'm usin python I thought I could give a try :-) > Here is the problem, I'm trying to write a regex in order to substitute > all the occurences in the form $"somechars" with another string. This is > what I wrote: > > newstring = re.sub(ur"""(?u)(\$\"[\s\w]+\")""", subst, oldstring) > > This works pretty well, but it has a problem, I would need it also to > handle the case in which the internal string contains the double quotes, > but only if preceeded by a backslash, that is something like > $"somechars_with\\"doublequotes". Can anyone help me to correct it? > > Thanks in advance! Hi! Next snippet works for me: re.sub(r'\$"([\s\w]+(\\")*[\s\w]+)+"', 'noop', r'$"te\"sts\"tri\"ng"') -- https://mail.python.org/mailman/listinfo/python-list
Why is augmented assignment of a tuple with iterable unpacking invalid syntax?
a = 1, 2, 3 b = *a, # assignment - OK b += *a, # augmented assignment - syntax error Need to enclose in parenthesis: b += (*a,) Why isn't it allowed with an augmented assignment, while it is OK with a regular assignment? -- https://mail.python.org/mailman/listinfo/python-list
Re: Tkinter or Python issue?
"Ron Provost" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > [snip] > t.insert( Tk.END, sampleText ) > > t.tag_config( 'AB', font=tkFont.Font( family='ariel', size=24, > weight=tkFont.BOLD ) ) > t.tag_config( 'TBU', font=tkFont.Font( family='times', size=10, > weight=tkFont.BOLD, underline=1 ) ) > > t.tag_add( 'AB', '1.8', '1.15' ) > t.tag_add( 'TBU', '2.10', '2.30' ) > > root.mainloop( ) > [snip] tkFont.Font(...) is a class instance, while you need font description. Try: t.tag.config( 'TBU', font=('times', 12, 'bold','underline') ) t.tag_config( 'AB', font=('arial',24,'bold') ) Eugene -- http://mail.python.org/mailman/listinfo/python-list
Re: drawline
Hi Ben, if I understood your questions properly, this code gives some answers (on XP): from Tkinter import * lines = [ [ (100, 200, 350, 200), LAST, "red",'' ], [ (100, 0, 100, 200), FIRST, "green", 'a' ], [ (100, 200, 300, 100), LAST, "purple", 'b' ], ] ClickMax = len(lines) ClickNum = 0 lasttag = '' def drawline(event): global ClickNum,lasttag canvas.delete(lasttag) line = lines[ClickNum] canvas.create_line(line[0], arrow=line[1], fill=line[2],tag=line[3]) lasttag = line[3] ClickNum = (ClickNum+1) % ClickMax ClickNum = ClickNum or 1 canvas = Canvas(Tk(), bg="white", bd=0, highlightthickness=0) canvas.pack(fill=BOTH, expand=YES) drawline(0) canvas.bind("<1>", drawline) canvas.mainloop() Eugene "Ben Bush" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I had the following code and when I clicked the left mouse button one time. I got green line and the second click got a purple line and the green disappeared. I was confused by two questions: First, Clicknum increases when every time I click the button. Is it possible to reset Clicknum to 0? Second, how to do something like: I click the left button the first time, the green line appear then disappear, the purple line appear(just as the code has done but become a loop; if a second-time click is implied, the loop stops. from Tkinter import * ClickNum = 0 def drawline(event): global ClickNum if ClickNum == 0: canvas.create_line(100, 0, 100, 200, arrow=FIRST,fill="green",tag="a") elif ClickNum == 1: canvas.delete("a") canvas.create_line(100, 50, 60, 300, arrow=FIRST,fill="purple") ClickNum += 1 tk = Tk() canvas = Canvas(tk, bg="white", bd=0, highlightthickness=0) canvas.pack(fill=BOTH, expand=YES) canvas.create_line(100, 200, 350, 200, arrow=LAST,fill='red') canvas.bind("<1>", drawline) tk.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: tkFileDialog.askopenfilename filetypes problem
For me this: z = tkFileDialog.askopenfilename(title='Title', filetypes=[ ('AIFF Files','*.aiff'), ("TXT Files", "*.txt"), ], initialdir=InputDir) print z works fine. Eugene "Justin Straube" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hopefully someone can catch what im missing here. Ive googled this and I think > Ive got the filetypes arg written properly, but I get a traceback when calling > this function. > > Heres the code followed by its traceback. > > def do_ask_fn_1(): > z = askopenfilename(title=TITLE, initialdir=Dst_Dir, > filetypes=(('AIFF Files','*.aiff'), > ("AU Files", "*.au"), > ("RAW Files", "*.raw"), > ("SD Files", "*.sd"), > ("SND Files", "*.snd"), > ("WAV files", "*.wav") > ) > ) > print z > > > Exception in Tkinter callback > Traceback (most recent call last): >File "E:\PYTHON~1\lib\lib-tk\Tkinter.py", line 1345, in __call__ > return self.func(*args) >File "P:\work\Python\PYZoid\PYZoid.pyw", line 213, in do_ask_fn_1 > filetypes=[('AIFF Files','*.aiff'), > TypeError: askopenfilename() takes exactly 0 non-keyword arguments (1 given) > > Can anyone point to what Ive done wrong? Thanks for any input. > > Justin -- http://mail.python.org/mailman/listinfo/python-list
What to use for installation?
Hello! I wrote a crossplatform Glade/GTK+ application for learning foreign languages (it is called Snakememory but doesn't have site in English yet). Currently it works from the directory where it was unpacked. But I need installation script that will compile and install translations, install application on Unix or create installation bundle for Windows. I have a three choices: distutils, make and scons. I think that distutils can't handle many tasks and make will require installing the whole cygwin for packaging on Windows, so the only remaining choice is scons. But I want to know other opinions before going with scons. What is the best tool for installing python applications? Eugene -- http://mail.python.org/mailman/listinfo/python-list
Development infrastructure - need python packaging gurus help, please
Hi! I'm trying to create a development infrastructure that would allow for simple and unified ways of sharing, *deploying* and *reusing* the code within private entity. I can see that pip with virtual environments and requirements.txt is very similar to dependency management provided by maven or apache ivy. But there seems to be a disconnect between the egg carrying the possibility to be importable and executable, but in the same time considered to be deprecated format which is not fully supported by pip and virtualenv and wheel not having those basic questions answered... Here is what i'm trying to achieve: 1. I want to be able to specify the set of dependencies for the project i'm currently developing and make them available for the import. Think java jar - having it in class path allows for the code reuse (import packages provided) as well as for the execution. 2. I want to be able to put the newly created project in a form of artifact in a some central location from which it can be taken to be imported or executed or included into "class path". Again think java jar. If i have it in some location i can use ivy or maven to manage the dependencies and provide it to me upon request 3. I want to be able to deploy the program and execute it. So the problem with all this as i see it: The importable and executable format is egg, but it is deprecated! Sane dependency management is pip and virtualenv, but they don't support eggs fully (pip install --egg is having the disclaimer that it s not working ok sometimes) wheel is pretty much unusable for anything other then installing into the virtualenv. Am i missing something? Thanks in advance, Eugene -- https://mail.python.org/mailman/listinfo/python-list
Re: Cross-platform issue with wxRadioBox
I have updated my script to use wx.RadioButton instead, which works perfectly on my mac again, but now the submit button doesn't show up on the pc and I can't click in the netid field on the pc either. any ideas? # BEGIN CODE import wx; SUBMIT_BUTTON = wx.ID_HIGHEST + 10; class regFrame(wx.Frame): def __init__(self, parent, title): wx.Frame.__init__(self, parent, -1, title, pos=(100, 100), size=(800, 600)); fileDialog = wx.FileDialog(self, "Select a file to which to write", style = wx.SAVE | wx.OVERWRITE_PROMPT, wildcard="*.txt|Text"); if(fileDialog.ShowModal() != wx.ID_OK): print "No file specified - closing"; self.Close(); return; write_file = fileDialog.GetPath(); self.write_file = open(write_file, "a"); # init main frame with menu and status bars self.panel = wx.Panel ( self, -1 ) menuBar = wx.MenuBar(); fileMenu = wx.Menu(); fileMenu.Append(wx.ID_ABOUT, "&About\tAlt-A", "About this program"); fileMenu.AppendSeparator(); fileMenu.Append(wx.ID_EXIT, "&Quit\tAlt-Q", "Quit this program"); menuBar.Append(fileMenu, "&File"); self.SetMenuBar(menuBar); self.CreateStatusBar(); self.ctrl_sizer = wx.GridBagSizer(5, 15); # build the controls instructions = " Enter your netid and size in the " + \ "boxes below and press the 'Submit Order' button to place " + \ "your order."; self.instruction_text = wx.StaticText(self, -1, instructions); self.id_text = wx.StaticText(self, -1, " netid"); self.id_input = wx.TextCtrl(self, -1, "", size=(160, -1)); self.size_text = wx.StaticText(self, -1, "size"); self.submit_button = wx.Button(self, SUBMIT_BUTTON, "Submit Order"); # put the controls into a grid self.ctrl_sizer.Add(self.instruction_text, (0, 0), span=(1, 3), flag=wx.EXPAND); self.ctrl_sizer.Add(self.id_text,(1, 0), flag=wx.EXPAND); self.ctrl_sizer.Add(self.size_text, (1, 1), flag=wx.EXPAND); self.ctrl_sizer.Add(self.id_input, (2, 0), flag=wx.HORIZONTAL); # TO MODIFY THE LIST OF SIZES, CHANGE THIS: self.valid_sizes = ['4XLT', '3XLT', '2XLT', '2XL', 'XLT', 'XL', 'LT', 'L', 'M', 'S', 'XS', 'XXS']; first_size = 1; size_count = 0; self.button_array = []; for this_size in self.valid_sizes: this_button = ''; if first_size: this_button = wx.RadioButton(self.panel, -1, this_size, style=wx.RB_GROUP); first_size = 0; else: this_button = wx.RadioButton(self.panel, -1, this_size); self.button_array.append(this_button); self.ctrl_sizer.Add(this_button, (size_count+2, 1)); size_count += 1; self.ctrl_sizer.Add(self.submit_button, (2, 2), flag=wx.HORIZONTAL); self.SetSizer(self.ctrl_sizer); self.ctrl_sizer.Fit(self); # register event handling functions wx.EVT_MENU(self, wx.ID_ABOUT, self.OnAbout); wx.EVT_MENU(self, wx.ID_EXIT, self.OnExit); wx.EVT_BUTTON(self, SUBMIT_BUTTON, self.OnSubmit); def OnAbout(self, evt): return; def OnExit(self, evt): if(self.write_file): self.write_file.close(); self.Close(); def OnSubmit(self, evt): selected_index = -1; this_index = 0; for this_button in self.button_array: if this_button.GetValue(): selected_index = this_index; this_index += 1; # make sure the user selected something if selected_index == -1: wx.MessageBox("You must select a size to place your order", "Please select a size", wx.ICON_EXCLAMATION); return; # build a tab-delimited-text line of the data and write it save_fields = [self.id_input.GetValue(), self.valid_sizes[selected_index]]; save_str = "\t".join(save_fields); # ask for validation before we save dialog_str = "Are you sure this is correct?" + \ "\n Netid: " + save_fields[0] + \ "\n Size: " + save_fields[1]; if(wx.MessageBox(dialog_str, "Confirm Order", wx.YES_NO | wx.ICON_EXCLAMATION) == wx.YES): # write it out and flush the buffer to make sure it's on disk self.write_file.write(save_str + "\n"); self.write_file.flush(); wx.MessageBox("Your order has been saved. Thanks!"); # reset the controls for the next user self.id_input.SetValue('');
Re: Make Tkinter child window active
Try: > > Label(c, text="Child window").grid() c.focus_set() > root = Tk() "Svennglenn" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > How do i make a child window "active" like the root window? > > from Tkinter import * > > def open_child(): > c = Toplevel(root) > c.title("Child window") > c.geometry('200x160+230+130') > > Label(c, text="Child window").grid() > > root = Tk() > root.title("root window") > > Button(root, text="Open child window", command=open_child).grid() > > root.mainloop() > > > When the child windows opens i would like it to be active like the > root window, how can i easily do that? > -- http://mail.python.org/mailman/listinfo/python-list
Re: Tough Scrolling question with Tkinter
Hi Saqib, AFAIU, you want to change the scrollregion, not the size. So try: def _b1PressEvt(event): x0,y0,x1,y1 = canvas.config('scrollregion')[4] print x0,y0,x1,y1 canvas.config(scrollregion=(int(x0),int(y0),int(x1)+100,int(y1))) First click will show nothing, because first change keeps the scrollregion entirely in the window. Eugene <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Please take a look at and run the code snippet shown below. > > It creates a canvas with vertical & Horizontal scroll-bars. > If you shrink the window to smaller than the area of the canvas, the > scroll-bars work as advertised. That's great. > > However, if you click the Left Mouse button, it calls code which > expands the width of the canvas by 100 pixels. The area being viewed > expands correspondingly. BUT I DON'T WANT IT TO!! > > I want to know how to expand the size of a canvas without changing the > area/size of what is currently shown by the scroll bars. I would like > to find code that expands the width of the canvas and simply adjusts > the H-Scrollbar without changing what is shown on in the area of the > canvas being displayed. > > I have tried seemingly every combination of messing with the > canvas.config and scrollregion parameters to no avail. Can someone out > there show me how its done?? > > -Saqib > > - > import Tkinter > > def _b1PressEvt(event): > print "B1" > _canvas.config(width=300) > > tkRoot = Tkinter.Tk() > _canvas = Tkinter.Canvas(tkRoot, background="white", width=200, > height=200,) > > # Scroll Bars > vScrollbar = Tkinter.Scrollbar(tkRoot) > vScrollbar.pack(side=Tkinter.RIGHT, expand=True, fill=Tkinter.Y) > > hScrollbar = Tkinter.Scrollbar(tkRoot) > hScrollbar.pack(side=Tkinter.BOTTOM, expand=True, fill=Tkinter.X) > > _canvas.config( > width=200, > height=200, > scrollregion=(0,0,100,100), > yscrollcommand=vScrollbar.set, > xscrollcommand=hScrollbar.set, > ) > > vScrollbar.config(orient=Tkinter.VERTICAL, command=_canvas.yview) > hScrollbar.config(orient=Tkinter.HORIZONTAL, command=_canvas.xview) > > #tkRoot.pack() > _canvas.pack(expand=Tkinter.NO) > vScrollbar.pack(side=Tkinter.RIGHT, expand=True, fill=Tkinter.Y) > hScrollbar.pack(side=Tkinter.BOTTOM, expand=True, fill=Tkinter.X) > > # Function Bindings > _canvas.bind("", _b1PressEvt) > > tkRoot.mainloop() > -- http://mail.python.org/mailman/listinfo/python-list
Re: Indenting in Emacs
Steven W. Orr пишет: > Ok. I'm not stupid but I do not see a 4.78 anywhere even though I see refs > from google. I have 4.75 The SVN tree doesn't seem to even have that. > > I checked the latest copy out from sourceforge and that was 4.75 too. > > Can someone please tell me where to find the latest? > It's from Emacs 22. Eugene -- http://mail.python.org/mailman/listinfo/python-list
pyosd question
Small script used to work, by last week I noticed that it simply hangs up. Can someone run this code on his own python and tell me about results? Help me please. import time import pyosd import re default_font="-adobe-helvetica-medium-r-*-*-24-*" interval = 2 temp_led_number = pyosd.osd(default_font, colour='#038b06', timeout=1,pos=pyosd.POS_BOT,offset=40,shadow=1,align=pyosd.ALIGN_CENTER) def display(): # Here it will stay forever temp_led_number.display('123', pyosd.TYPE_STRING) # Never reach this line :( print "Yeah!" while 1: display() time.sleep(interval) -- Sincerely, Eugene Antimirov PortaOne, Inc., SIP Engineer [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie question
kavitha thankaian wrote: > Hi, > > i wrote a simple script (which follows) to insert a table in the > database.i could execute this query and get the result in python > shell.but when i open "my sql enterprise manager" i couldnt find the > table"animals".it would be so kind of you if someone could help me,,, > > > import dbi > import odbc > conn=odbc.odbc("DSN=mydatabase;UID=xxx;PWD=yyy") > cursor=conn.cursor() > cursor.execute("Create table animals(parent char(50),child char(50))") > cursor.execute("insert into animals values('lion','cub')") > cursor.execute("insert into animals values('goat','lamb')") > cursor.execute("select * from animals") > print cursor.fetchall() > > > Rgds > Kavitha > > You've probably missed cursor.commit() ;) -- Sincerely, Eugene Antimirov PortaOne, Inc., SIP Support Engineer [EMAIL PROTECTED] * For further Billing and Technical information: => Please visit our website http://www.portaone.com => Please visit our forum http://forum.portaone.com * Meet us at Internet Telephony Conference & Expo * Ft. Lauderdale, FL - January 24-26, 2007 - Booth 1322 * http://www.tmcnet.com/voip/conference/ -- http://mail.python.org/mailman/listinfo/python-list
Re: newbie question
Eugene Antimirov wrote: > You've probably missed cursor.commit() ;) Sorry, my bad: conn.commit() is correct one AFAIR. -- Sincerely, Eugene Antimirov PortaOne, Inc., SIP Support Engineer [EMAIL PROTECTED] * For further Billing and Technical information: => Please visit our website http://www.portaone.com => Please visit our forum http://forum.portaone.com * Meet us at Internet Telephony Conference & Expo * Ft. Lauderdale, FL - January 24-26, 2007 - Booth 1322 * http://www.tmcnet.com/voip/conference/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Working with shared folders
Marcpp wrote: > Any idea to work with windows shared folders? > Which library is needed to execute console comands? > Don't you want to look at fusesmb first and then work with windows files and dirs as well as with any others. -- Sincerely, Eugene Antimirov PortaOne, Inc., SIP Support Engineer [EMAIL PROTECTED] * For further Billing and Technical information: => Please visit our website http://www.portaone.com => Please visit our forum http://forum.portaone.com * Meet us at Internet Telephony Conference & Expo * Ft. Lauderdale, FL - January 24-26, 2007 - Booth 1322 * http://www.tmcnet.com/voip/conference/ -- http://mail.python.org/mailman/listinfo/python-list
Re: another newbie question: why should you use "*args" ?
stef wrote: > # method 2 > def chunk_plot(self, list): > for i in range ( len(list) ): > do something And one note more. Just to be more pythonic you shouldn't use form range(len(blabla)). Instead use: for i in list: blabla... -- Sincerely, Eugene Antimirov PortaOne, Inc., SIP Support Engineer [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list
Setting an exclusive lock on a file
Hi all, I want to set an exclusive lock on a file so other processes wouldn't be able to write to it. So I write import fcntl fd=open('myfile','w') fcntl.lockf(fd, fcntl.LOCK_EX) fd.write('some bytes') fd.close() But it turns out that my script doesn't write anything to file whereas other processes do. What's wrong in my code? -- Sincerely yours, Eugene Perederey -- http://mail.python.org/mailman/listinfo/python-list
Re: List of paths
Sure, generators rock! :-) 2009/4/1 andrew cooke : > Nico Grubert wrote: >>> May be not so much pythonic, but works >>> >>> for i in range(len(q)): >>> for x in q[i:]: >>> if x.startswith(q[i]) and x!=q[i]: >>> q.remove(x) >> >> ...but works fine. Thanks, Eugene. >> Also thanks to Andrew. Your example works fine, too. Thanks to remind me >> of the 'yield' statement! ;-) > > in case it's not clear, the method above is O(n^2) while mine was O(n). > that will not matter for small lists, but for long ones mine will be much > faster. > > andrew > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Sincerely yours, Eugene Perederey > -- Sincerely yours, Eugene Perederey -- http://mail.python.org/mailman/listinfo/python-list
cross platform ping module
Hi all! I'm interested in developing a cross platform module that will allow a simple 'ping' functionality, i mean sending icmp type 8 code 0 and receiving appropriate answers. This sound like a simple work, but i ask for your help with architectural decision. I can implement icmp communications using raw sockets (possibly, as an extension coded in C), or i can use subproccess module, ask system ping executable to do the work, and just parse it's output. There are problems with both solutions. First one will require root (or equivalent) privileges for the interpreter to work. This is unavoidable, we can just make the program suid, but sometimes (as to my mind, always) it is not an option. Security matters, i can't allow each and every untested application to run with root privileges. Besides, this will require the user to actually have root access to make program suid. I'm unsure about the way something similar to suid can be done on windows, too. Second one just plain looks ugly to me. I don't like the approach at all. But, this would avoid all security troubles with suid, because if the user can run ping, we can too. And this also mean sysadmin actually allowed the user to run ping. On the other hand, this will limit us to icmp types that concrete system's ping executable can work with. This means that on some systems we can use only type 8/ type 0 (i would like to use few others too). If i just needed a tool for specific environment, i would have easily chosen. But i'm going to create a module that everyone and everywhere could use. >From this point of view, calling system ping looks better. Can you please help me choose the correct way to handle this problem? Maybe, there are some other possibilities, witch i haven't taken into account? Is someone here interested in this functionality, anyway? Sorry for my poor English. -- http://mail.python.org/mailman/listinfo/python-list
Re: a newbie question
use urllib2 2009/4/12 : > hi, > > I am just learning Python and get a problem when trying this example: > > from urllib import urlopen > doc=urlopen("http://www.python.org";).read() > print(doc) > > when i run this, i was tould that 'cannot import name "urlopen" > > > What's wrong with this code? Do i need to place my code in some > specific directory? Thanks a lot. ' > -- > http://mail.python.org/mailman/listinfo/python-list > -- Sincerely yours, Eugene Perederey -- http://mail.python.org/mailman/listinfo/python-list
Re: regex alternation problem
According to documentation re.findall takes a compiled pattern as a first argument. So try patt = re.compile(r'(am|an)') re.findall(patt, s1) re.findall(patt, s2) 2009/4/18 Jesse Aldridge : > import re > > s1 = "I am an american" > > s2 = "I am american an " > > for s in [s1, s2]: > print re.findall(" (am|an) ", s) > > # Results: > # ['am'] > # ['am', 'an'] > > --- > > I want the results to be the same for each string. What am I doing > wrong? > -- > http://mail.python.org/mailman/listinfo/python-list > -- Sincerely yours, Eugene Perederey -- http://mail.python.org/mailman/listinfo/python-list
calling command line programs?
Hi all, This is probably a very newbie question, but after searching google and docs @ python.org I can't find an answer, so maybe someone would be able to help? I'd like to call command-line functions from my python script (like you would in perl using backticks)... Is there a way of doing this? And if so, how does the environment get treated (I have some variables in my env that the programs I'd be calling need to see). Thanks much! Eugene -- http://mail.python.org/mailman/listinfo/python-list
poplib.retr doens't flag message as read
Hi there, I am trying to use the poplib library to get emails using the retr method. The small program bellow works but the message aren't flagged as read which puzzles me. I believe the pop server is qmail 1.0.6 / vpopmail 5.2.1 and I am running the following script on Windows using Pyhton 2.5. import poplib import email pop = poplib.POP3('mail.server.com') pop.user('[EMAIL PROTECTED]') pop.pass_('password') status, msg_list, octets = pop.list() for msg_number in [msg.split(' ')[0] for msg in msg_list]: status, lines, octets = pop.retr(msg_number) msg = email.message_from_string('\n'.join(lines)) if not msg.is_multipart() and msg.get_content_type() == 'text/plain': print msg.get('Subject') print msg.get_payload() pop.quit() Why aren't the message flagged as read? Is there a way to manually mark them read? Thanks, EuGeNe -- http://www.3kwa.com -- http://mail.python.org/mailman/listinfo/python-list
Re: poplib.retr doens't flag message as read
Gabriel Genellina wrote: > The POP protocol has no concept of "read" or "unread" messages; the LIST > command simply shows all existing messages. My mistake, I guess I was confused by the documentation retr( which) Retrieve whole message number which, and set its seen flag. Result is in form (response, ['line', ...], octets). What is the seen flag? Nothing it seems http://mail.python.org/pipermail/python-list/2005-July/329888.html Thanks for your help, EuGeNe -- http://www.3kwa.com -- http://mail.python.org/mailman/listinfo/python-list
Re: ORM layer
David wrote: > I am looking for an ORM for Python that fulfills a few simple needs. * SQLObject * SQLAlchemy (+Elixir) * DejaVu There are probably others but these are the most commonly used AFAIK. EuGeNe -- http://www.3kwa.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Access to file dropped on .exe/.app icon
Martin wrote: > If i create an app using py2exe/py2app is there then a way on windows/ > mac to get access to a file dragged and dropped on to the .exe/.app > icon? > > Martin > I did something like that for a small program I wrote to learn more about Python Programming on Windows ... check it out http://www.3kwa.com/Tutorial/PumpItUp EuGeNe -- http://www.3kwa.com -- http://mail.python.org/mailman/listinfo/python-list
EuroPython vs PyconUK
I do realize that the UK is not really part of Europe (no polemic :P) but I am nevertheless curious about the logic behind creating another major Python event in Europe. Wasn't EuroPython enough? Like many I am sure, I probably won't be able to attend both (and I really enjoyed the Geneva experience so definitely want to renew "it"). How would you go about selecting which conference to attend? They are only 2 months apart, 6 would have been easier for the attendees! Could the organizers liaise one way or another to make Pythoneers life as easy and fun as the language and give as much information out as possible as early as possible (early bird early) for people to make the best decision? I know marketing matters but ... EuGeNe -- http://www.3kwa.com -- http://mail.python.org/mailman/listinfo/python-list
Re: EuroPython vs PyconUK
Steve Holden wrote: > So by this reasoning there should have been no "Python UK" conference > for the last four years (in case you didn't know it ran as a track of > the C/C++ conference, but ths track has now broadened to include all > scripting languages). And what about the people who can't get the time > and/or money to attend EuroPython? I am afraid there is a misunderstanding. I have no problem with PyCon UK but would like to have elements to help me choose (the official language of PyCon Uno Italy is Italian so that fixes it :P). > Diversity is good, so it isn't one vs. the other. And the UK really *is* > part of Europe (no matter how its politicians behave) :P I agree that diversity is good (you won't hear me say that there are too many web frameworks in Python :D) but isn't dilution a danger? If Guido was a rock star and I was a groupie, I would want to know which festival to attend to see him on stage. I guess there is always Google Video ;) More seriously in Geneva there were people from all over the place, speakers and attendees, which is one of the reason why such conferences are interesting (or am I deluded?). It is harder for someone from Australia to come twice to Europe in the space of 2 months than for a pythoneer lambda to spend a couple of days studying another web framework to see if it fits how his brain works and the problem he's got to solve. Looking at the reactions to my post, I must be wrong. I didn't mean to offend anyone if I did. I'll go to Vilnius because I have never seen the city and try to go to Birmingham if the program looks interesting (not very rational or is it?). Cheers, EuGeNe -- http://www.3kwa.com -- http://mail.python.org/mailman/listinfo/python-list
Re: EuroPython vs PyconUK
Fuzzyman wrote: > I assume you have the same problem with the Italian one? Not so much because the official language of Pycon Uno Italy is Italian so I don't feel too concerned (unfortunately my Italian is not quite good enough). > Seriously though, it is *great* to see the UK Python scene flourishing > (and the Italian one). The more events that happen the better, and I > don't think they need be in competition with each other... I *hope* > the Europython guys don't see it like that. I agree it is great to see the Python scene grow (everywhere). The AFPY is organizing "journees python francophones" early June too cf. http://journees.afpy.org/. I have only been to one conference before so I may be under the wrong impressions but I don't see how the three events won't be competing for Ri (as in Shu Ha Ri) speakers for example. Do I sound like a groupie? Alex Martelli, brilliant speaker and Python evangelist (in my Shu Ha eyes anyway), lives in the States and is Italian. Busy as you'd expect from someone working for Google, decides to make the trip to Europe for a Python related conference, henceforth spends 3 1/2 months in Europe so he can do Italy in June (he is listed as an organizer), Lithuania in July and UK in September... I don't know how the EuroPython guys see it. Cheers, EuGeNe -- http://www.3kwa.com -- http://mail.python.org/mailman/listinfo/python-list
Re: EuroPython vs PyconUK
Alex Martelli wrote: > I like the kudos, thanks!, but I'm not quite sure what you're saying > about my travel plans... just to clarify, once again I'll have to miss > EuroPython _and_ PythonUK, two events I attended most assiduously when I > was living in Europe (but then, for two years running I've also missed > PyCon, _despite_ living in the US, sigh). I was just using your possible travel plans as an example to express my "concerns" :P Re your effective travel plans, thanks God for Google Video then :D Cheers, EuGeNe -- http://www.3kwa.com -- http://mail.python.org/mailman/listinfo/python-list
Re: EuroPython vs PyconUK
Michele Simionato wrote: > I don't see the problem. In my view EuroPython is the big event in > Europe. If you can > go to only one conference and you have the possibility to travel to > Vilnius, then go to EuroPython. > The national conferences are of interest primarily for people of that > national (of course, not > exclusively). Thanks, I didn't see it that way but that was ignorance on my behalf. I was WRONGLY under the impression that we were in front of a classical European pattern named "what WE can do collectively I can do better alone" - known use : European constitution :P (but I am digressing :D). > BTW, this year I will go both to PyCon It and EuroPython, last year I > went both to > PyUK and EuroPython. The more, the better ;) The more the merrier indeed in that respect! I learnt a lot from your "Using decorators" talk last year. Thanks. EuGeNe -- http://www.3kwa.com -- http://mail.python.org/mailman/listinfo/python-list
base64 and unicode
Hi, I am trying to convert the file hebrew.b64 attached into hebrew.lang (text file usable by Inline Search <http://www.ieforge.com/InlineSearch> for localization purposes. >>> import base64 >>> base64.decode(file("hebrew.b64","r"),file("hebrew.lang","w")) It runs but the result is not correct: some of the lines in hebrew.lang are correct but not all of them (hebrew.expected.lang is the correct file). I guess it is a unicode problem but can't seem to find out how to fix it. hebrew.b64 = file to convert //4jACAARQBuAGcAbABpAHMAaAAgAHYAIAAxAC4ANAANAAoAMQA6AOIF0QXoBdkF6gUNAAoA DQAKADEAMAAxADoA0QXZBdgF1QXZBSAA3AXQBSAA4AXeBeYF0AUNAAoAMQAwADIAOgDUBdIF 2QXiBSAA3AXhBdUF4wUgANQF0wXjBSwAIADeBd4F6QXZBdoFIADeBegF0AXpBSAA1AXTBeMF DQAKADEAMAAzADoA0gXoBeEF1AUgANcF0wXpBdQFIADpBdwFIABJAG4AbABpAG4AZQAgAFMA ZQBhAHIAYwBoACAA4AXeBeYF0AXUBS4AIADcBdcF5QUgAOIF3AUgACIA2wXfBSIAIADbBdMF 2QUgANwF4gXRBdUF6AUgANwF0wXjBSAA1AXUBdUF6AXTBdQFLgANAAoAMQAwADQAOgDZBekF IADcBdoFIADQBeoFIADUBdIF6AXhBdQFIADUBdAF1wXoBdUF4AXUBSAA6QXcBSAASQBuAGwA aQBuAGUAIABTAGUAYQByAGMAaAAuAA0ACgAxADAANQA6AN4F5gXQBSAAOgANAAoAMQAwADYA OgDUBeoF0AXdBSAA6AXZBekF2QXVBeoFDQAKADEAMQAxADoA3gXmBdAFIADQBeoFIADUBdEF 0AUNAAoAMQAxADIAOgDeBeYF0AUgANAF6gUgANQF5wXVBdMF3QUNAAoAMQAxADMAOgDUBdMF 0gXpBSAA1AXbBdwFDQAKAA0ACgAjACAATQBlAG4AdQANAAoAMwAyADcANgA4ADoA0AXVBdMF 1QXqBQ0ACgAzADIANwA2ADkAOgDRBdMF1QXnBSAA0AXdBSAA5wXZBdkF3QUgAOIF0wXbBdUF 3wUNAAoAMwAyADcANwAwADoA1AXqBdAF3QUgANAF2QXpBdkF6gUuAC4ALgANAAoADQAKACMA IABPAHAAdABpAG8AbgAgAGQAaQBhAGwAbwBnAA0ACgAxADAANwA6ANQF6gXQBd0FIADQBdkF 6QXZBeoFIADQBeoFIABJAG4AbABpAG4AZQAgAFMAZQBhAHIAYwBoAA0ACgAxADAAOAA6AOkF 5AXUBQ0ACgAxADAAOQA6ANEF1wXoBSAA0AXqBSAA1AXpBeQF1AUgANQF3gXVBeIF0wXkBeoF IADiBdwF2QXaBSAAOgANAAoAMQAxADAAOgDpBdkF4AXVBdkF2QXdBSAA0QXpBeQF1AUgANkF 1QXkBdkF4gXVBSAA0QXUBeQF4gXcBdQFIADUBdEF0AXUBSAA6QXcBSAASQBuAHQAZQByAG4A ZQB0ACAARQB4AHAAbABvAHIAZQByAA0ACgA= hebrew.expected.lang = expected output # English v 1.4 1:עברית 101:ביטוי לא נמצא 102:הגיע לסוף הדף, ממשיך מראש הדף 103:גרסה חדשה של Inline Search נמצאה. לחץ על "כן" כדי לעבור לדף ההורדה. 104:יש לך את הגרסה האחרונה של Inline Search. 105:מצא : 106:התאם רישיות 111:מצא את הבא 112:מצא את הקודם 113:הדגש הכל # Menu 32768:אודות 32769:בדוק אם קיים עדכון 32770:התאם אישית... # Option dialog 107:התאם אישית את Inline Search 108:שפה 109:בחר את השפה המועדפת עליך : 110:שינויים בשפה יופיעו בהפעלה הבאה של Internet Explorer Could someone enlighten me on how to go from hebrew.b64 to hebrew.expected.lang? Thanks a lot, EuGeNe -- http://www.3kwa.com -- http://mail.python.org/mailman/listinfo/python-list
Re: base64 and unicode
Duncan Booth wrote: > However, the decoded text looks as though it is utf16 encoded so it should be > written as binary. i.e. > the output mode should be "wb". Thanks for the "wb" tip that works (see bellow). I guess it is experience based but how could you tell that it was utf16 encoded? > Simpler than using the base64 module you can just use the base64 codec. > This will decode a string to a byte sequence and you can then decode that > to get the unicode string: > > with file("hebrew.b64","r") as f: >text = f.read().decode('base64').decode('utf16') > > You can then write the text to a file through any desired codec or process > it first. >>> with file("hebrew.lang","wb") as f: >>> ... file.write(text.encode('utf16')) Done ... superb! > BTW, you may just have shortened your example too much, but depending on > python to close files for you is risky behaviour. If you get an exception > thrown before the file goes out of scope it may not get closed when you > expect and that can lead to some fairly hard to track problems. It is much > better to either call the close method explicitly or to use Python 2.5's > 'with' statement. Yes I had shortened my example but thanks for the 'with' statement tip ... I never think about using it and I should ;) Thanks, EuGeNe -- http://www.3kwa.com -- http://mail.python.org/mailman/listinfo/python-list
Re: preferred windows text editor?
T. Crane wrote: > Right now I'm using Notepad++. What are other people using? > > trevis > > VIM here as well ... here we go again :P EuGeNe -- http://www.3kwa.com -- http://mail.python.org/mailman/listinfo/python-list
file / module / package - import problem
Hi there, I have a "problem" which could be a bad design on my behalf but I am not sure so ... I have a package WMI which contains a module hauteur.py which, when imported, load data from a file located in WMI/data/. In hauteur.py I call open('data/hauteur.yaml'). test.py WMI/ hauteur.py data/ hauteur.yaml lot.py It works well when hauteur is imported in lot.py but if I try import WMI.hauteur in test.py it doesn't work because it looks for the hauteur.yaml file in the "wrong" place. Is there a way to tell a module in a package to look for a file in a specific place i.e. a within package location? Thanks, EuGeNe -- http://www.3kwa.com -- http://mail.python.org/mailman/listinfo/python-list
Re: file / module / package - import problem
aspineux wrote: > import os.path > > file=open(os.path.join(os.path.dirname(__file__), 'hauteur.yaml')) Thanks that worked ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: ActiveRecord for Python/MySQL
Devraj wrote: > My application uses MySQL as a backend and am using the MySQL/Python > bindings. Are there any libraries that provide a database abstraction > layer like Activerecords for Python?' SQLObject SQLAclhemy DejaVu Storm Google for Python ORM you may find more! EuGeNe -- http://www.3kwa.com -- http://mail.python.org/mailman/listinfo/python-list
python sqlite THREADSAFE?
Hi, Is the sqlite distributed with Python 2.5 compiled with the -DTHREADSAFE=1 flag? My gutt feeling is Windows (yes) MacOS/Linux (no) but ... If it is not on MacOS/Linux, how do I go about replacing the sqlite so file with a threadsafe sqlite? Thanks, EuGeNe -- http://www.3kwa.com -- http://mail.python.org/mailman/listinfo/python-list