Comparing UTF-8 into USC-2 and vice versa (newbie :-) )
I recently rewrote a .net application in python. The application is basically gets streams via TCP socket and handle operations against an existing database. The Database is SQLite3 (Encoded as UTF-8). The Networks streams are encoded as UCS-2. Since in UCS-2, 'A' = '0041' and when I check with the built-in functions I get for unicode("A", "utf-8") = u'A' = u'\u0041'. I wonder what is the difference, and how can I safely encode/decode UCS-2 streams and match them with the UTF-8 representation -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing UTF-8 into USC-2 and vice versa (newbie :-) )
On Jun 17, 10:48 am, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > I recently rewrote a .net application in python. > > The application is basically gets streams via TCP socket and handle > > operations against an existing database. > > The Database is SQLite3 (Encoded as UTF-8). > > The Networks streams are encoded as UCS-2. > > > Since in UCS-2, 'A' = '0041' and when I check with the built-in > > functions I get for unicode("A", "utf-8") = u'A' = u'\u0041'. I > > wonder what is the difference, and how can I safely encode/decode > > UCS-2 streams and match them with the UTF-8 representation > > In unicode("A", "utf-8"), the "utf-8" parameter does *not* mean > that the output is in UTF-8, but the *input*. > So "A" = '41' != '0041'. In UCS-2, the A consumes two bytes; in > UTF-8, it consumes only one byte. > > For different letters, that's different: For example, for u'\xf6', > the UCS-2 representation (big-endian) is '00F6', for UTF-8, it is > 'C3B6'. For u'\u20AC', the UCS-2 is '20AC', the UTF-8 is 'E282AC' > (i.e. three bytes). > > You should use Unicode objects in your program always, and encode > to or from UCS-2 or UTF-8 only when interfacing with the > network/database. > > HTH, > Martin Thanks Martin for this guideline -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing UTF-8 into USC-2 and vice versa (newbie :-) )
On Jun 17, 10:48 am, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > > I recently rewrote a .net application in python. > > The application is basically gets streams via TCP socket and handle > > operations against an existing database. > > The Database is SQLite3 (Encoded as UTF-8). > > The Networks streams are encoded as UCS-2. > > > Since in UCS-2, 'A' = '0041' and when I check with the built-in > > functions I get for unicode("A", "utf-8") = u'A' = u'\u0041'. I > > wonder what is the difference, and how can I safely encode/decode > > UCS-2 streams and match them with the UTF-8 representation > > In unicode("A", "utf-8"), the "utf-8" parameter does *not* mean > that the output is in UTF-8, but the *input*. > So "A" = '41' != '0041'. In UCS-2, the A consumes two bytes; in > UTF-8, it consumes only one byte. > > For different letters, that's different: For example, for u'\xf6', > the UCS-2 representation (big-endian) is '00F6', for UTF-8, it is > 'C3B6'. For u'\u20AC', the UCS-2 is '20AC', the UTF-8 is 'E282AC' > (i.e. three bytes). > > You should use Unicode objects in your program always, and encode > to or from UCS-2 or UTF-8 only when interfacing with the > network/database. > > HTH, > Martin Thanks Martin for this guideline. But in fact say I get a USC-2 string and need to compare it with UTF-8 value in the database. How can I do it given the Python built-in libraries? -- http://mail.python.org/mailman/listinfo/python-list
Re: Comparing UTF-8 into USC-2 and vice versa (newbie :-) )
Yet, 'utf_16_be' is not 'ucs-2'. How would I get ucs-2 encoding and decoding functionality with python? -- http://mail.python.org/mailman/listinfo/python-list
MaildirMessage
I am getting the following error when trying to iterate in a message in a Maildir directory. please help. >>> from mailbox import Maildir, MaildirMessage >>> mbox = Maildir('path/to/mailbox', create = False, factory = MaildirMessage) >>> for msg in mbox: ... for m in msg: ... print m ... Traceback (most recent call last): File "", line 2, in File "email/message.py", line 286, in __getitem__ File "email/message.py", line 352, in get AttributeError: 'int' object has no attribute 'lower' >>> -- http://mail.python.org/mailman/listinfo/python-list
Re: MaildirMessage
> Which is a bug in the 'email.message' module, in my view. If it's > attempting to support a mapping protocol, it should allow iteration > the same way standard Python mappings do: by iterating over the keys. I thought it is a bug as well, but who am I a python newbie to say so. I found inspect.getmembers(msg) as a good solution to map the message properties. 10x, Tzury -- http://mail.python.org/mailman/listinfo/python-list
Re: MaildirMessage
> What do you actually think > > ... for m in msg: > ... print m > > should do? Why do you believe that what you think it should do would be > a natural choice? I needed to know how to extract particular parts of a message, such as the message 'body', 'subject', 'author', etc. I couldn't find it in the documentation this kind of information until I ran the inspect.getmembers(msg) and found out that the message body stored in _payload. that is msg._payload is the content of the message. Regarding the *bug* thing it is very simple. If you iterate an int you get an exception , clear enough. Yet here I got the following exception which suggest an attempt to iterate ---. I do think that a message should support iteration for the very fact that each can contain a different type and amount of headers, and iteration in this case will make application's code clean and unified. -- http://mail.python.org/mailman/listinfo/python-list
ctypes, windll question
I followed the tutorial about ctypes and I still cannot figure out how to call a method of a calss within the dll. For example: a dll named 'foo' contain a class named 'bar' which expose a method named 'baz'. if I either do: mydll = windll.foo mycls = mydll.bar or mycls = windll.foo.bar or mycls = windll.foo.bar() I get an erros: "function 'bar' not found " which is true since while bar is a class. Yet, I need to know how to create an instance of this inner class so I can access its public methods. -- http://mail.python.org/mailman/listinfo/python-list
ctypes windll question
I followed the tutorial about ctypes and I still cannot figure out how to call a method of a calss within the dll. For example: a dll named 'foo' contain a class named 'bar' which expose a method named 'baz'. if I either do: mydll = windll.foo mycls = mydll.bar or mycls = windll.foo.bar or mycls = windll.foo.bar() I get an erros: "function 'bar' not found " which is right, since bar is a class and not a function. However, I still need to create an instance of this inner class (bar) so I can access its public method (baz). I cannot find anywhere instructions for that. -- http://mail.python.org/mailman/listinfo/python-list
Re: ctypes windll question
I discovered pywin32-210.win32-py2.5 package which does all the work for me. Open Software world is a great place to live by On Aug 14, 12:45 pm, Tzury <[EMAIL PROTECTED]> wrote: > I followed the tutorial about ctypes and I still cannot figure out how > to call a method of a calss within the dll. > > For example: > a dll named 'foo' contain a class named 'bar' which expose a method > named 'baz'. > > if I either do: > > mydll = windll.foo > mycls = mydll.bar > > or > mycls = windll.foo.bar > > or > mycls = windll.foo.bar() > > I get an erros: "function 'bar' not found " which is right, since bar > is a class and not a function. However, I still need to create an > instance of this inner class (bar) so I can access its public method > (baz). > > I cannot find anywhere instructions for that. -- http://mail.python.org/mailman/listinfo/python-list
How to query a unicode data from sqlite database
Can anyone tell the technique of composing a WHERE clause that refer to a unicode data. e.g. "WHERE FirstName = ABCD" where ABCD is the unicoded first name in the form that sqlite will match with its records. -- http://mail.python.org/mailman/listinfo/python-list
Setting System Date And Time
Is it possible to modify the Systems' Date and Time with python? -- http://mail.python.org/mailman/listinfo/python-list
Having fun with python
def loadResMap(self): self.resMap = [] [[self.resMap.append(str('A2' + sim[0] + '/r' + str(x))) for x in range(1, eval(sim[1])+1)] for sim in [x.split(':') for x in quickViews.smsResList.v.split(",")]] ''' # Confused? Have this one: data = quickViews.smsResList.v sims, slots = [], data.split(",") for slot in slots: sims.append(slot.split(':')) for sim in sims: for x in range(1, eval(sim[1])+1): self.resMap.append(str('A2' + sim[0] + '/r' + str(x))) # same functionality different approaches # forloops vs. list comprehension # redability vs. smartassicity # AKA: You have read too many Lisp books ''' -- http://mail.python.org/mailman/listinfo/python-list
Python, Embedded linux and web development
Regarding the platform described below, can anyone suggest from his experience what would be the best library choice to develop the following application. a) application that deals with data transformed via TCP sockets. b) reading and writing to and from sqlite3 (include Unicode manipulations). c) small web application that will be used as front end to configure the system (flat files and sqlite3 db are the back-end). Our platform is base on the Intel PXA270 processor (XSCALE family, which is ARM compatible) running at 312MHz. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python, Embedded linux and web development
On Feb 27, 2:27 pm, "Paul Boddie" <[EMAIL PROTECTED]> wrote: > On 27 Feb, 13:12, "Tzury" <[EMAIL PROTECTED]> wrote: > > > > > c) small web application that will be used as front end to configure > > the system (flat files and sqlite3 db are the back-end). > > > Our platform is base on the Intel PXA270 processor (XSCALE family, > > which is ARM compatible) running at 312MHz. > > You might want to read this article which got mentioned fairly > recently either on comp.lang.python or on some blog or other: > > http://www.linuxdevices.com/articles/AT5550934609.html > > Paul Thanks for the quick response. good article -- http://mail.python.org/mailman/listinfo/python-list
querying unicode data (sqlite) with python
Given an sqlite db that stores the strings data such as names, etc. encoded in Unicode. How do I write a sql query statement with 'LIKE' or '=' operators and insert the Unicoded name. for example: in table MY_TABLE, in column COL01 there is a value "¿Habla español?" within python I represent this value as u'\u00bfHabla espa\u00f1ol?' if I wish to produce a query that will fetch this row something like "SELECT * FROM MY_TABLE WHERE COL01="¿Habla español?" and I want it to be done dynamically according to data I receive from a tcp socket. -- http://mail.python.org/mailman/listinfo/python-list
Re: Having fun with python
> However, one point you have shown very clearly: the second one is much > easier to tear apart and reassemble. Sure. Zen Of Python: Readbility Counts -- http://mail.python.org/mailman/listinfo/python-list
a simple tcp server sample
hi, the following sample (from docs.python.org) is a server that can actually serve only single client at a time. In my case I need a simple server that can serve more than one client. I couldn't find an example on how to do that and be glad to get a hint. Thanks in advance import socket HOST = '127.0.0.1' # Symbolic name meaning the local host PORT = 50007# Arbitrary non-privileged port s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((HOST, PORT)) s.listen(1) conn, addr = s.accept() print 'Connected by', addr while 1: data = conn.recv(1024) if not data: break conn.send(data) conn.close() -- http://mail.python.org/mailman/listinfo/python-list
Re: a simple tcp server sample
> Even simpler, use Twisted: I am afraid Twisted is not the right choice in my case. I am looking for smaller, simpler and minimal server sample. -- http://mail.python.org/mailman/listinfo/python-list
Re: a simple tcp server sample
> See the SocketServer module, both the documentation and the source code. I firstly looked at this module and its __doc__, yet I still need an 'hello world' sample. and couldn't get it straight how can I write my own hello world sample with SocketServer objects. -- http://mail.python.org/mailman/listinfo/python-list
Re: a simple tcp server sample
here is its: # a simple tcp server import SocketServer class EchoRequestHandler(SocketServer.BaseRequestHandler ): def setup(self): print self.client_address, 'connected!' self.request.send('hi ' + str(self.client_address) + '\n') def handle(self): while 1: data = self.request.recv(1024) self.request.send(data) if data.strip() == 'bye': return def finish(self): print self.client_address, 'disconnected!' self.request.send('bye ' + str(self.client_address) + '\n') #server host is a tuple ('host', port) server = SocketServer.ThreadingTCPServer(('', 50008), EchoRequestHandler) server.serve_forever() -- http://mail.python.org/mailman/listinfo/python-list
100% CPU Usage when a tcp client is disconnected
The following is a code I am using for a simple tcp echo server. When I run it and then connect to it (with Telnet for example) if I shout down the telnet the CPU tops 100% of usage and saty there forever. Can one tell what am I doing wrong? #code.py import SocketServer class MyServer(SocketServer.BaseRequestHandler ): def setup(self): print self.client_address, 'connected!' self.request.send('hi ' + str(self.client_address) + '\n') def handle(self): while 1: data = self.request.recv(1024) self.request.send(data) if data.strip() == 'bye': return def finish(self): print self.client_address, 'disconnected!' self.request.send('bye ' + str(self.client_address) + '\n') #server host is a tuple ('host', port) server = SocketServer.ThreadingTCPServer(('', 50008), MyServer) server.serve_forever() -- http://mail.python.org/mailman/listinfo/python-list
Re: 100% CPU Usage when a tcp client is disconnected
> data = "dummy" > while data: > ... Thanks Alot -- http://mail.python.org/mailman/listinfo/python-list
Re: 100% CPU Usage when a tcp client is disconnected
Thank Hrvoje as well -- http://mail.python.org/mailman/listinfo/python-list
To PEAK or not to PEAK
I am about to start a large-scale enterprise project next month (I insist on using Python instead Java and .NET and I am sure `they` will thank me eventually). I was wondering around making my components-and-libraries-shopping- list and came across PEAK. My paranoia is that PEAK would make me write my application in PEAK instead of Python (I felt that in the past with Django). Therefore, I would like to hear the voices of you which have any experience with PEAK. Whether you are using it or used it in the past or tried to use it and abandoned it. How happy were you while using it? How simple it is to use? -- http://mail.python.org/mailman/listinfo/python-list
encoding/decoding issue with python2.5 and pymssql
hi, in my table the field row_id is type of uniqueidentifier. when try to fetch the data, pymssql somehow, encodes the values in a way which yields odd results. for example: the value 'EE604EE3-4AB0-4EE7-AF4D-018124393CD7' is represent as '\xe3N`\xee\xb0J\xe7N\xafM\x01\x81$9<\xd7' the only way I manged to pass this is by converting the value into varchar at the server side. I would like to solve this at the python side and not in the database for several obvious reasons see example: >>> conn = mymssql.connect(**connection_details) >>> cur = conn.cursor() >>> sql = "select row_id, cast(row_id as varchar(36)) from table_a" >>> cur.execute(sql) >>> rows = cur.fetchall() >>> rows[0] ('\xe3N`\xee\xb0J\xe7N\xafM\x01\x81$9<\xd7', 'EE604EE3-4AB0-4EE7- AF4D-018124393CD7') >>> >>> -- http://mail.python.org/mailman/listinfo/python-list
Re: encoding/decoding issue with python2.5 and pymssql
These are not cut&paste but typed by hand, yet they are identical to the actual output. seems like the first 8 bytes are swapped while the other half is straightforward. I deeply thank you for your assistance. I am currently using a combination of reversed and list comprehension to rebuild this byte array. On Mar 24, 8:48 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Sun, 23 Mar 2008 22:33:58 -0700 (PDT), Tzury Bar Yochay > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > for example: > > the value > > 'EE604EE3-4AB0-4EE7-AF4D-018124393CD7' > > is represent as > > '\xe3N`\xee\xb0J\xe7N\xafM\x01\x81$9<\xd7' > > Are those direct cut&paste? > > >>> "".join(["%2.2X" % ord(x) for x in > >>> '\xe3N`\xee\xb0J\xe7N\xafM\x01\x81$9<\xd7']) > > 'E34E60EEB04AE74EAF4D018124393CD7' > > or, putting in - > > 'E34E60EE-B04A-E74E-AF4D-018124393CD7' > > The last half is a direct match... the front half looks to have some > byte-swapping > > E34E60EE => (swap shorts) 60EEE34E > 60EEE34E => (swap bytes) EE604EE3 > > B04A => 4AB0 > > E74E => 4EE7 > > Anything > onhttp://www.sqljunkies.com/Article/4067A1B1-C31C-4EAF-86C3-80513451FC0... > of any help (besides the facet of using a GUID to ID the page describing > GUIDs ) > > -- > Wulfraed Dennis Lee Bieber KD6MOG > [EMAIL PROTECTED] [EMAIL PROTECTED] > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support Staff: [EMAIL PROTECTED]) > HTTP://www.bestiaria.com/ -- http://mail.python.org/mailman/listinfo/python-list
behavior varied between empty string '' and empty list []
while I can invoke methods of empty string '' right in typing (''.join(), etc.) I can't do the same with empty list example: >>> a = [1,2,3] >>> b = [].extend(a) >>> b >>> b = [] >>> b.extend(a) >>> b [1,2,3] I would not use b = a since I don't want changes on 'b' to apply on 'a' do you think this should be available on lists to invoke method directly? -- http://mail.python.org/mailman/listinfo/python-list
Inheritance question
given two classes: class Foo(object): def __init__(self): self.id = 1 def getid(self): return self.id class FooSon(Foo): def __init__(self): Foo.__init__(self) self.id = 2 def getid(self): a = Foo.getid() b = self.id return '%d.%d' % (a,b) While my intention is to get 1.2 I get 2.2 I would like to know what would be the right way to yield the expected results -- http://mail.python.org/mailman/listinfo/python-list
Re: Inheritance question
On Mar 25, 2:00 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Mar 25, 10:44 pm, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote: > > > > > given two classes: > > > class Foo(object): > > def __init__(self): > > self.id = 1 > > > def getid(self): > > return self.id > > > class FooSon(Foo): > > def __init__(self): > > Foo.__init__(self) > > self.id = 2 > > > def getid(self): > > a = Foo.getid() > > b = self.id > > return '%d.%d' % (a,b) > > > While my intention is to get 1.2 I get 2.2 > > I would like to know what would be the right way to yield the expected > > results > > Post the code that you actually executed. What you have shown lacks > the code to execute it ... but the execution will fail anyway: > > a = Foo.getid() > TypeError: unbound method getid() must be called with Foo instance as > first argument (got nothing instead) sorry, it should have been: a = Foo.getid(self) instead of a = Foo.getid() -- http://mail.python.org/mailman/listinfo/python-list
Re: Inheritance question
> Rather than use Foo.bar(), use this syntax to call methods of the > super class: > > super(ParentClass, self).method() Hi Jeff, here is the nw version which cause an error class Foo(object): def __init__(self): self.id = 1 def getid(self): return self.id class FooSon(Foo): def __init__(self): Foo.__init__(self) self.id = 2 def getid(self): a = super(Foo, self).getid() b = self.id return '%d.%d' % (a,b) FooSon().getid() Traceback (most recent call last): File "a.py", line 19, in FooSon().getid() File "a.py", line 14, in getid a = super(Foo, self).getid() AttributeError: 'super' object has no attribute 'getid' -- http://mail.python.org/mailman/listinfo/python-list
Re: Inheritance question
On Mar 25, 4:03 pm, Anthony <[EMAIL PROTECTED]> wrote: > On Mar 25, 11:44 am, Tzury Bar Yochay <[EMAIL PROTECTED]> wrote: > > > While my intention is to get 1.2 I get 2.2 > > I would like to know what would be the right way to yield the expected > > results > > Is this what you want? > > class Foo(object): > def __init__(self): > self.id = 1 > def getid(self): > return self.id > > class FooSon(Foo): > def __init__(self): > Foo.__init__(self) > self.id = 2 > def getid(self): > a = Foo().getid() > b = self.id > return '%d.%d' % (a,b) > > >>> FooSon().getid() > > '1.2' > > Best wishes, > Anthony I wish it was that simple but 'a = Foo().getid()' is actually creating a new instance of Foo whereas I want the data of the Foo instanced by __init__ of FooSon(). what I am actually trying to do is to build a set of classes which handle different type of binary messages coming from the network. a base message which handles its basic data parts (src, dst, etc.) and extending it per message type. thus I looked for a way to get the child calling super for parsing the super's prats and then having the child parsing its additional details. -- http://mail.python.org/mailman/listinfo/python-list
Re: Inheritance question
Hi all, I would like to thank you all for all the suggestions. what I did was simply extending the super class data with data from its child using the id example, Foo.id = 1 is now = [1] and the FooSon does self.id.append(2) the system designer wanted inheritance+java and I wanted Python +Functional Programming i guess we will meet somewhere in the middle thanks again tzury -- http://mail.python.org/mailman/listinfo/python-list
Re: Py2exe embed my modules to libary.zip
> and then when my application execute code how can I set path to > d3dx module to "library.zip/d3dx.py". > I'm not sure is this properly set question. use the module zipimport http://docs.python.org/lib/module-zipimport.html -- http://mail.python.org/mailman/listinfo/python-list
chronic error with python on mac os/x 10.5
Although I am experiencing this problem using a specific domain library (pjsip). Googling this issue show that it is happening to many libraries in python on mac. I was wondering whether anyone solved this or alike in the past and might share what steps were taken. Note: this python lib works fine on other platforms (posix, win, and earlier versions of mac os x) >>> import py_pjsua Traceback (most recent call last): File "", line 1, in ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.5/ lib/python2.5/site-packages/py_pjsua.so, 2): Symbol not found: ___CFConstantStringClassReference Referenced from: /Library/Frameworks/Python.framework/Versions/2.5/ lib/python2.5/site-packages/py_pjsua.so Expected in: dynamic lookup -- http://mail.python.org/mailman/listinfo/python-list
os.environ.get('SSH_ORIGINAL_COMMAND') returns None
Trying to follow a technique found at bzr I did the following added to ~/.ssh/authorized_keys the command="my_parder" parameter which point to a python script file named 'my_parser' and located in / usr/local/bin (file was chmoded as 777) in that script file '/usr/local/bin/my_parser' I got the following lines: #!/usr/bin/env python import os print os.environ.get('SSH_ORIGINAL_COMMAND', None) When trying to ssh e.g. 'ssh localhost' I get None on the terminal and then the connection is closed. I wonder if anyone have done such or alike in the past and can help me with this. Is there anything I should do in my python file in order to get that environment variable? -- http://mail.python.org/mailman/listinfo/python-list
AttributeError: 'module' object has no attribute 'DatagramHandler' (ubuntu-8.10, python 2.5.2)
$ ~/devel/ice/snoip/freespeech$ python Python 2.5.2 (r252:60911, Oct 5 2008, 19:24:49) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import logging >>> logging.DatagramHandler Traceback (most recent call last): File "", line 1, in AttributeError: 'module' object has no attribute 'DatagramHandler' >>> That is odd since the documentation says there is DatagramHandler for module logging -- http://mail.python.org/mailman/listinfo/python-list
why does math.pow yields OverflowError (while python itself can calculate that large number)
What is the reason math.pow yields OverflowError while python itself can calculate these large numbers. e.g: >>> import math >>> math.pow(100, 154) 1e+308 >>> math.pow(100, 155) Traceback (most recent call last): File "", line 1, in OverflowError: math range error >>> eval(('100*'* 155)[:-1]) 100 000 000 000 000 L >>> -- http://mail.python.org/mailman/listinfo/python-list
Re: why does math.pow yields OverflowError (while python itself can calculate that large number)
> Because math.pow returns a float; 100 ** 155 won't fit in a float. Sure that is the reason. May I rephrase, my question: Why not returning another type as long as we can calculate it? After all, math module is likely to be used on large numbers as well. -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the time of message Received of an outlook mail in python..
On Oct 23, 12:04 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi,, > How can we access the time of message received ( UTC time) of an > outlook mail in python? As far as I know the time which it displays in > the mail is not the exact time... this UTC time will be present in > MIME Header of an outlook mail. > > Any Help is appreciated..and thanks in advance,, > Venu. You may google for how to utilize outlook using OLE-COM automation When finding out how, implement it using python's com wrappers -- http://mail.python.org/mailman/listinfo/python-list
a py2exe feature for non-windows environments
Hi, The nicest thing I like about py2exe is its library.zip which encapsulate all the dependencies into one single file. I wonder if there a script which can do the same for linux/mac osx so one can ship a python solution as a single file (instead of starting easy_install per used library on the target machine). -- http://mail.python.org/mailman/listinfo/python-list
Re: a py2exe feature for non-windows environments
> Mac OS X:http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html Found these for linux: http://www.pyinstaller.org/ http://wiki.python.org/moin/Freeze thanks alot -- http://mail.python.org/mailman/listinfo/python-list
how to free memory allocated by a function call via ctypes
Hi, Suppose I have the following function char *generateMessage(char *sender, char *reciever, char *message) ; now in c I would normally do char *msg = generateMessage(sender, reciever, message); // do something free(msg); My question is how do I free the memory allocated when I call this function using ctypes I could not find this in the documentation for python 2.5 thanks -- http://mail.python.org/mailman/listinfo/python-list
trying to use SOCK_RAW yields error "
I am trying to create raw socket: server = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.getprotobyname('ip')) As a result I get the following error: Traceback (most recent call last): File "tcpsrv.py", line 14, in server = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.getprotobyname('ip')) File "/usr/lib/python2.5/socket.py", line 154, in __init__ _sock = _realsocket(family, type, proto) socket.error: (93, 'Protocol not supported') Does anybody have used socket.SOCK_RAW in the past? -- http://mail.python.org/mailman/listinfo/python-list
Re: trying to use SOCK_RAW yields error "
> When using SOCK_RAW, the family should be AF_PACKET, > not AF_INET. Note that you need root privileges to do so. I changed as instructed: server = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.getprotobyname('ip')) now I am getting: Traceback (most recent call last): File "tcpsrv.py", line 15, in server.bind((host,port)) File "", line 1, in bind socket.error: (19, 'No such device') -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with sqlite
after executing insert do conection.commit() -- http://mail.python.org/mailman/listinfo/python-list
Re: Phyton module for Windows Event Viewer?
> Can someone point me in the right direction? I'm looking for a module > to monitor the Windows Event Viewer. http://docs.python.org/lib/module-logging.html NTEventLogHandler is the one you should use. happy pythoning -- http://mail.python.org/mailman/listinfo/python-list
Simple UDP server
I am looking for the right way to write a small and simple UDP server. I am wondering between Forking, Threading (found at SocketServer.py) and the one describes at the snippet below. Can you tell me the advantages and disadvantages of each Would the one below will be capable of holding 30 concurrent connections? I have no intention of using Twisted or alike since I am looking for making it as lightweight as possible Thanks in advance, Tzury Bar Yochay # begin of snippet from socket import * # Create socket and bind to address UDPSock = socket(AF_INET,SOCK_DGRAM) UDPSock.bind(('',50008)) while 1: data,addr = UDPSock.recvfrom(4*1024) if not data: print "No data." break else: print 'from:', addr, ' data:', data UDPSock.close() -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple UDP server
On Sep 10, 9:55 pm, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > Tzury Bar Yochay wrote: > > Would the one below will be capable of holding 30 concurrent > > connections? > > UDP is a connectionless datagram protocol, so that question doesn't > really make much sense. > So what if it is connectionless. It would make sense if you get a load of users who sends large sets of binary data to each other. -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple UDP server
> Transmitting large binary data over UDP? That makes only sense for few > applications like video and audio streaming. UDP does neither guarantee > that your data is received nor it's received in order. For example the > packages A, B, C, D might be received as A, D, B (no C). > > Can your protocol handle missing packages and out of order packages? I intend of using it for audio transmission and don't care about lose or out of order. -- http://mail.python.org/mailman/listinfo/python-list
writeable buffer and struct.pack_into and struct.unpck_from
Hi, I can't find in the documentation the way to use these two functions. can someone share a simple code that utilize these two functions? -- http://mail.python.org/mailman/listinfo/python-list
Re: writeable buffer and struct.pack_into and struct.unpck_from
Thanks Gabriel, I was missing the information how to create a writable buffer. -- http://mail.python.org/mailman/listinfo/python-list