parsing non-ascii characters
Hello all, I have a list: suffix = ["aĉ", "ad", "aĵ", "an", "ar"] and I'm trying to check a word to see if any of the suffixes exist in the list for example: if word in suffix: print "A suffix exist in your word" when I run this it give me an error: SyntaxError: Non-ASCII character '\xc5' in file vortaro.py on line 33, but no encoding declared; is there a way to parse Non-ASCII characters in python? Thanks in advance, Ronn -- http://mail.python.org/mailman/listinfo/python-list
print from a python script.
I'm trying to print a simple string to a network printer. This is what I have so far: import os printer_path = "192.168.200.139" p = os.popen(printer_path, 'w') p.write("this is a printer test") p.close() I'm trying to call the printer from its IP address. When I run the script I get: sh: 192.168.200.139: not found thanks for you help in advance. -- http://mail.python.org/mailman/listinfo/python-list
Scraping a web page
I'm using the following to scrape a web page: import urllib f = urllib.urlopen("http://www.google.com";) s = f.read() It is working, but it's returning the source of the page. Is there anyway I can get almost a screen capture of the page? Dankon -- http://mail.python.org/mailman/listinfo/python-list
Sorting a dictionary
I'm attempting to sort for the results of a dictionary. I would like to short by the 'key' in ascending order. I have already made several attempts using: sorted() and .sort(). Here is my loop: for key,value in word_count.items(): print sorted(key), "=", value Thanks -- http://mail.python.org/mailman/listinfo/python-list
Tkinter file dialog
I'm using Tkinter file selector to get a direcotry path. I'm using: self.file = tkFileDialog.askdirectory(title="Please select your directory") print file but all it prints out is: How would I print the directory path? Thanks -- http://mail.python.org/mailman/listinfo/python-list
RFID and Python
I'm looking to play around with RFID and Python. Can anyone offer any suggestions on the cheap? I'm possibly looking for a starter kit. -- http://mail.python.org/mailman/listinfo/python-list
Re: Welcome to the "Python-list" mailing list
This is my first post and I'm new to Python. How would someone go about adding keywords to Python? It would be great to add support for Esperanto keywords in the language instead of English being the only option. thx -- http://mail.python.org/mailman/listinfo/python-list
playing around with python
Hello all, I downloaded the source for version 2.5.2 and I played around and made some changes, but now I don't know how to compile on my machine to test them. Can someone tell me how to compile it to run on my machine? I'm trying to get familiar with it before I volunteer. Also, I'm running Unbuntu Linux. Thanks, Ronn -- http://mail.python.org/mailman/listinfo/python-list
playing around with python
Hello, I download the source for -- http://mail.python.org/mailman/listinfo/python-list
New to python
I have recently come across something called a struct. I have googled this, but have note found a good explanation. Can someone give me a good definition or point me to a page that has one. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Python and USB
I'm new to Python and would like to capture mouse movements. I envision writing a script that will just write out the mouse movements in the term. Is this possible? Can someone point me in the right direction? -- http://mail.python.org/mailman/listinfo/python-list
Pyusb
I'm running Python 2.6 on windows. I'm install Pyusb and I'm having trouble including the library in my script. Can someone point me in the right direction to get this working or know of a good tutorial to help me out. Best regards -- http://mail.python.org/mailman/listinfo/python-list
Pyusb
Does anyone know where I can download a copy of PyUSB 1.0? I can only find 0.x versions on sourceforge. I'm following a tutorial that requires 1.0. Thanks -- http://mail.python.org/mailman/listinfo/python-list
reading joystick data
Hello, I'm using PyUSB 0.4.2 to interact with a Microsoft Sindwinder joystick. I'm using python 2.6 on windows XP. With the code snippet below I'm able to find usb device currently plugged into my computer. Now I would like to actually tap into the data that to joystick is providing to the system. For now I just want to watch the data and see what it looks like as I move the joystick around. Does anyone know a good tutorial, or can point me in the right direction? Script: import usb for bus in usb.busses(): for dev in bus.devices: print "Bus %s Device %s: ID %04x:%04x %s" % (bus.dirname, dev.filename, dev.idVendor, dev.idProduct, dev.open().getString(1,30)) Result: Bus bus-0 Device \\.\libusb0-0005--0x04f2-0xb071: ID 04f2:b071 CNF7129 Bus bus-0 Device \\.\libusb0-0006--0x045e-0x0038: ID 045e:0038 Microsoft -- http://mail.python.org/mailman/listinfo/python-list
PySerial
I'm using pySerial to connect to a serial port (rs232) on a windows xp machine. I'm using python interactive interpretor to interact with the device. I type the following: import serial ser = serial.Serial(2) ser.write("command") But this does nothing to the control. I have been able to connect via puTTY to verify that the command and the device are working. Next I tried to open the port before writing. It looks like this: import serial ser = serial.Serial(2) ser.open() It returns that an error. It states that I do not have permissions? I don't know how to resolve either issue. Any help would be greatly appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: PySerial
I'm using pySerial to connect to a serial port (rs232) on a windows xp machine. I'm using python interactive interpretor to interact with the device. I type the following: import serial ser = serial.Serial(2) ser.write("command") But this does nothing to the control. I have been able to connect via puTTY to verify that the command and the device are working. Next I tried to open the port before writing. It looks like this: import serial ser = serial.Serial(2) ser.open() It returns that an error. It states that I do not have permissions? I don't know how to resolve either issue. Any help would be greatly appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Re: PySerial
I have tried setting the baud rate with no success. Also I'm using port #2 because I"m using a usb to serial cable. On Fri, Oct 23, 2009 at 7:51 PM, Chris Rebert wrote: > On Thu, Oct 22, 2009 at 4:43 PM, Ronn Ross wrote: > > I'm using pySerial to connect to a serial port (rs232) on a windows xp > > machine. I'm using python interactive interpretor to interact with the > > device. I type the following: > > import serial > > ser = serial.Serial(2) > > ser.write("command") > > > > But this does nothing to the control. I have been able to connect via > puTTY > > to verify that the command and the device are working. Next I tried to > open > > the port before > > writing. It looks like this: > > import serial > > ser = serial.Serial(2) > > ser.open() > > > > It returns that an error. It states that I do not have permissions? I > don't > > know how to resolve either issue. Any help would be greatly appreciated. > > Have you tried setting the baud rate? (the `baudrate` param to > Serial's constructor) > Why are you using port #2 and not #0? > > Cheers, > Chris > -- > http://blog.rebertia.com > -- http://mail.python.org/mailman/listinfo/python-list
Re: PySerial
Yes, with the serial to usb adapter is located on COM3. I have been able to use puTTY to get into the port and shoot commands at the device, but when I try to use python I get 'You don't have permissions". On Sat, Oct 24, 2009 at 12:50 AM, Gabriel Genellina wrote: > En Fri, 23 Oct 2009 20:56:21 -0300, Ronn Ross > escribió: > > > I have tried setting the baud rate with no success. Also I'm using port #2 >> because I"m using a usb to serial cable. >> > > Note that Serial(2) is known as COM3 in Windows, is it ok? > > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: PySerial
On Sat, Oct 24, 2009 at 4:53 PM, John Nagle wrote: > Gabriel Genellina wrote: > >> En Fri, 23 Oct 2009 20:56:21 -0300, Ronn Ross >> escribió: >> >> >> I have tried setting the baud rate with no success. Also I'm using port >>> #2 >>> because I"m using a usb to serial cable. >>> >> >> Note that Serial(2) is known as COM3 in Windows, is it ok? >> > > Do you have a machine with a COM3 port? > >John Nagle Yes, I have verified that there is a COM3. I connected to it using puTTY. I was able to access the device from puTTY. -- http://mail.python.org/mailman/listinfo/python-list
Python GUI
I need to create a gui for python. I'm looking for something that is easy to learn and cross platform. Any suggestions? If you have any good tutorials please send along. Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python GUI
Philip, PySide looks nice and you are right it is still very young. I'm still going to give it a try. Thanks for your help. On Sun, Oct 25, 2009 at 9:41 PM, Philip Semanchuk wrote: > > On Oct 25, 2009, at 8:39 PM, Ronn Ross wrote: > > I need to create a gui for python. I'm looking for something that is easy >> to >> learn and cross platform. Any suggestions? If you have any good tutorials >> please send along. Thanks in advance. >> > > wxPython (which wraps wxWidgets) is popular and IMO reasonably well laid > out. I hear great things about PyQt (which wraps QT) but I haven't used it. > PySide is a new wrapper for QT that has generated a lot of excitement but is > still its infancy, I think. > > > HTH > Philip > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Adding a menu to Tkinter
I'm attempting to add a menu bar to my Tkinter app. I can't figure out the correct syntax. Can someone help? I get this error when I run the app: Traceback (most recent call last): File "tkgrid.py", line 26, in app = App(root) File "tkgrid.py", line 10, in __init__ menubar = Menu(master).grid(row=0) File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk/Tkinter.py", line 1859, in grid_configure + self._options(cnf, kw)) _tkinter.TclError: can't manage ".4300345712": it's a top-level window from Tkinter import * class App: def __init__(self, master): def hello(): print "hello!" menubar = Menu(master).grid(row=0) menubar.add_command(label="Hello!", command=hello) Label(master, text="First").grid(row=1) Label(master, text="Second").grid(row=2) e1 = Entry(master) e2 = Entry(master) e3 = Entry(master) e1.grid(row=0, column=1) e2.grid(row=1, column=1) e2.grid(row=2, column=1) root = Tk() app = App(root) root.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: Python 2.6 Global Variables
Inside the method that you want to use the var prefix the first instance with global. For example: global my_var. Then you can use the var like normal in the method. Good luck On Oct 28, 2009, at 20:50, mattofak wrote: Hi All; I'm new to Python and moving from C, which is probably a big source of my confusion. I'm struggling with something right now though and I hope you all can help. I have a global configuration that I would like all my classes and modules to be able to access. What is the correct way to do this? Thanks; Matthew Walker -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
converting latitude and longitude
I'm attempting to convert latitude and longitude coordinates from degrees minutes and second to decimal form. I would like to go from: N39 42 36.3 W77 42 51.5 to: -77.739855,39.70 Does anyone know of a library or some existing out their to help with this conversion? -- http://mail.python.org/mailman/listinfo/python-list
[no subject]
I'm attempting to convert latitude and longitude coordinates from degrees minutes and second to decimal form. I would like to go from: N39 42 36.3 W77 42 51.5 to: -77.739855,39.70 Does anyone know of a library or some existing out their to help with this conversion? -- http://mail.python.org/mailman/listinfo/python-list
packaging apps
I have a simple application that has a glade file and a .py file. How would I package that into an installer for Windows, Mac, and a deb file? Can anyone point me in the right direction? -- http://mail.python.org/mailman/listinfo/python-list
VirtualEnv
I'm attempting to write a bootstrap script for virtualenv. I just want to do a couple of easy_install's after the environment is created. It was fairly easy to create the script, but I can't figure out how to implement it. The documentation was not of much help. Can someone please point me in the right direction? -- http://mail.python.org/mailman/listinfo/python-list
VirtualEnv
I'm attempting to write a bootstrap script for virtualenv. I just want to do a couple of easy_install's after the environment is created. It was fairly easy to create the script, but I can't figure out how to implement it. The documentation was not of much help. Can someone please point me in the right direction? -- http://mail.python.org/mailman/listinfo/python-list
TypeError: unbound method
Hello all, Created a python file that has a class and three methods. When I jump into interactive mode I import like so: from import Now when I try to use a method from the class: var1 = class.method() It give me this error: TypeError: unbound method must be called with instance as first argument (got int instance instead) I'm not sure what is going on event after consulting with google -- http://mail.python.org/mailman/listinfo/python-list
Beginners question
How do you define a global variable in a class. I tried this with do success: class ClassName: global_var = 1 def some_methos(): print global_var This doesn't work. What am I doing wrong? -- http://mail.python.org/mailman/listinfo/python-list
trouble with minidom
Hello I'm trying to read an xml file using minidome. The xml looks like: myProj /here/ My code looks like so: from xml.dom.minidom import parse dom = parse("myfile.xml") for node in dom.getElementsByTagName("project'): print('name: %s, path: %s \n') % (node.childNodes[0].nodeValue, node.childNodes[1]) Unfortunately, it returns 'nodeValue as none. I'm trying to read the value out of the node fir example name: myProj. I haven't found much help in the documentation. Can someone point me in the right direction? -- http://mail.python.org/mailman/listinfo/python-list
Re: trouble with minidom
On Tue, Jul 21, 2009 at 7:32 PM, Gabriel Genellina wrote: > En Tue, 21 Jul 2009 21:08:57 -0300, Ronn Ross > escribió: > > > Hello I'm trying to read an xml file using minidome. The xml looks like: >> >> >> myProj >> /here/ >> >> >> >> My code looks like so: >> from xml.dom.minidom import parse >> >> dom = parse("myfile.xml") >> >> for node in dom.getElementsByTagName("project'): >> print('name: %s, path: %s \n') % (node.childNodes[0].nodeValue, >> node.childNodes[1]) >> >> Unfortunately, it returns 'nodeValue as none. I'm trying to read the value >> out of the node fir example name: myProj. I haven't found much help in the >> documentation. Can someone point me in the right direction? >> > > Unless you have a specific reason to use the DOM interface (like having a > masochistic mind), working with ElementTree usually is a lot easier: > > py> import xml.etree.ElementTree as ET > py> xml = """ > ... > ...myProj > .../here/ > ... > ... """ > py> doc = ET.fromstring(xml) > py> for project in doc.findall('project'): > ... for child in project.getchildren(): > ... print child.tag, child.text > ... > name myProj > path /here/ > > -- > Gabriel Genellina > > -- > http://mail.python.org/mailman/listinfo/python-list > I have used the loop below and it works great, but I need get both child elements or 'project' per iteration. I want to build a dictionary that resemble this: my_dict = {'myProj':'/here/', 'anothername':'anotherpath'} I couldn't find how to do with in the element tree docs. Can you point me in the right direction? -- http://mail.python.org/mailman/listinfo/python-list
Can you easy_install from your localhost?
I have a package i would like to store locally. If it is stored locally can I do something like ' easy_install http://localhost/package ' ? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Barcodes
My company needs a small inventory management app. Does python have any libraries to help with reading and writing bar codes? -- http://mail.python.org/mailman/listinfo/python-list
Re: Barcodes
On Wed, Aug 19, 2009 at 9:19 AM, Ronn Ross wrote: > I was hoping that python would have a library to help me print my own bar > codes? We will need labels in all sizes and most label printer just work > with 1 or 2 sizes. I would like to just print a grid of different sizes on > standard paper. Does python have a bar code printing library? > > > > On Mon, Aug 17, 2009 at 4:55 PM, Tim Chase > wrote: > >> My company needs a small inventory management app. Does >>>> python have any libraries to help with reading and writing >>>> bar codes? >>>> >>> >>> I've written bar code apps and python really doesn't enter >>> into that part of things. Printers generally have bar code >>> printing capabilities so you just send the right escape >>> sequences and you get the bar codes. To read them, bar code >>> readers scan and translate before sending the values through >>> typically a keyboard wedge or serial port. >>> >> >> To add to what Emile mentions, most barcode readers present a >> keyboard-wedge interface, so that scanning a barcode merely appears as if >> you typed it at the keyboard (USB readers show up as a HID profile). Often >> they'll have configuration barcodes that you can scan to tweak the profile >> (such as pressing , or an arrow-key after sending the barcode; >> controlling beep tone & volume, etc). >> >> For printing barcodes, you can use any number of solutions -- the most >> popular usually just involves installing a "barcode font" and then rendering >> text in that font to your desired output canvas. I believe there are some >> native rendering solutions as well, but I've not investigated since the font >> method was more than sufficient for my wants. >> >> -tkc >> >> >> >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > > I found this library, but no documentation( https://cybernetics.hudora.biz/projects/wiki/huBarcode). Has anyone used this or know of a similar library with better documentation? -- http://mail.python.org/mailman/listinfo/python-list
convert date time
I'm new to python and I'm getting a date time from a field in the database that looks like this: 8/2/2009 8:36:16 AM (UTC) I want to split it into two fields one with the date formatted like this: -MM-DD 2009-08-02 and the time to be 24 hour or military time. How every you call it. Similar to this: 15:22:00 I found it easy to truncate off the (UTC), but having trouble converting the date. Can someone point me in the right direction? -- http://mail.python.org/mailman/listinfo/python-list
Re: convert date time
On Fri, Aug 21, 2009 at 2:26 PM, D'Arcy J.M. Cain wrote: > On Fri, 21 Aug 2009 14:14:32 -0400 > Ronn Ross wrote: > > I want to split it into two fields one with the date formatted like this: > > -MM-DD 2009-08-02 > > > > and the time to be 24 hour or military time. How every you call it. > Similar > > to this: > > 15:22:00 > > > > I found it easy to truncate off the (UTC), but having trouble converting > the > > date. Can someone point me in the right direction? > > You don't say what database you are using but you may find it simpler > to do the conversion in your SELECT statement. For example, see > http://www.postgresql.org/docs/8.3/static/functions-formatting.html for > PostgreSQL formatting functions. > > -- > D'Arcy J.M. Cain | Democracy is three wolves > http://www.druid.net/darcy/| and a sheep voting on > +1 416 425 1212 (DoD#0082)(eNTP) | what's for dinner. > I apologize I should have made it clear that this date is stored in the db as a string/varchar. The reason it is stored that way is before it's being read in from a text file where it is formatted that way. -- http://mail.python.org/mailman/listinfo/python-list
Reading binary files
I need to read a binary file. When I open it up in a text editor it is just junk. Does Python have a class to help with this? -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading binary files
On Mon, Aug 24, 2009 at 11:18 AM, Ronn Ross wrote: > > > On Mon, Aug 24, 2009 at 10:43 AM, Albert Hopkins > wrote: > >> On Mon, 2009-08-24 at 10:35 -0400, Ronn Ross wrote: >> > I need to read a binary file. When I open it up in a text editor it is >> > just junk. Does Python have a class to help with this? >> >> Yes, the "file" class. >> >> >>> myfile = open('/path/to/binary/file', 'rb') >> >> -a >> > This works for a simple binary file, but the actual file I'm trying to read > is give throwing an error that the file cannot be found. Here is the name of > the my file: > 2009.08.02_06.52.00_WA-1_0001_00_0662_0.jstars > > Should python have trouble reading this file name or extension? > I'm having trouble with the filename: 2009.08.02_06.52.00_WA-1_0001_00_0662_0.jstars It throws an error with that file name, When I change it to something like sample.txt it runs, but the data is still garbled. Is there any reason why I can't use the above file name? If I'm using 'rb' to read the binary file why is it still garbled? -- http://mail.python.org/mailman/listinfo/python-list