Storing dataset from Condtional FreqDist
Hello i have trying to store information in arff file but i has been really.
Any ideas of how can i do that?
with open('fileids3.txt', 'r') as f:
genres=[word.strip() for word in f.next().split(',')]
with open('adjectifs2.txt', 'r') as g:
adj = [word.strip() for word in g.next().split(',')]
freq = nltk.ConditionalFreqDist(
(genre, m)
for genre in brown.fileids()
for m in brown.words(fileids=genre))
freq.tabulate(conditions=genres, samples=adj)
--
https://mail.python.org/mailman/listinfo/python-list
Module Conflicts
I have a module named math.py in a package with some class definitions. I am trying to import the standard python math module inside of math.py but It seems to be importing itself. Is there any way around this problem without renaming my math.py file? -- http://mail.python.org/mailman/listinfo/python-list
Re: Module Conflicts
On Apr 9, 10:36 pm, Benjamin <[EMAIL PROTECTED]> wrote: > On Apr 9, 5:33 pm, Jose <[EMAIL PROTECTED]> wrote: > > > I have a module named math.py in a package with some class > > definitions. I am trying to import the standard python math module > > inside of math.py but It seems to be importing itself. Is there any > > way around this problem without renaming my math.py file? > > Not without some unpythonic magic. It's really not good style to name > a module the same as a stdlib one. It'll also confuse people reading > your code. Yeah but I thought since math.py was in a package, it would be okay. It's no big deal. I'll just rename my module :( -- http://mail.python.org/mailman/listinfo/python-list
Re: How to generate account number?
Hello Andriy Thanks for your work! I will try it! Jose On Fri, Nov 2, 2012 at 3:13 PM, Andriy Kornatskyy < [email protected]> wrote: > > Requirements for `account number` generator: > > 1. Issue pseudo random consistent number (must be unique for dozen > millions of records) > 2. Easy check validity (without a need to make a database call) > > Interested? Read more here: > > http://mindref.blogspot.com/2012/11/generate-account-number.html > > Comments or suggestions are welcome. > > Thanks. > > Andriy Kornatskyy > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
PIL or something to open EXIF Metadata with Python
I am trying to load the PIL module to manage exif metadata with Python but have had no success. I do some work relate with applescript, but for large files time increases exponentially. So I changed to Python with the intention of using PIL or something similar. I see that the last update of PIL is like 3 years ago, so I don't know if it is still working. I downloaded the last version of PIL to my mac, but I can't get python to recognize PIL included commands. Does anybody has a suggestion? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Is thera a Metakit for Python 2.4 release ??
Hi Do you know where I can find the Mk4py.dll for Python24 ?. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Where can I find Mk4py.dll for Python24?
Hi I changed for python24 and the only thing missed is metakit for python24. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Where can I find Mk4py.dll for python24 ?
I installed the new release and I have not been able to make work metakit. Please give me some help to enjoy metakit and python 24. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Sorry for the multiple posts !!
My broswser stoped working when I posted, and I tought it didn't work, so I tried a more times until did not report an error. Bye -- http://mail.python.org/mailman/listinfo/python-list
Re: Web Hosting
> With web hosting, does the ISP you chose have to support the framework > you work with as well? > > Im looking at making a site in Python, however, Im lost as to what ISPs > actually support. Some ISPs say they support Python so does that mean > if I wanted to use TurboGears It would just work anyway? > Check out http://webfaction.com... They have a one-click TurboGears installation procedure (as well as some other frameworks) but you can also install your own custom frameworks if they don't support it directly. HTH, -- http://mail.python.org/mailman/listinfo/python-list
quick script to read digital terrain elevation data?
I'm running python 2.3 on Windows XP. Anyone have a quick small script to convert .DT1 and .DEM data to ASCII or some other format? I don't need a viewer. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
how to select between two file libraries with same name?
Imagine my file one.py contains the statement import two If there's a two.py in same directory as one.py, then this file will be loaded. However, I want to load a different file named also two.py, say file ~username/mypythonlib/two.py How can I select between the two two.py files ? -jose -- http://mail.python.org/mailman/listinfo/python-list
Re: Python iPod challenge
Gabriel, Now it works fine with FIREFOX , SAFARI and MSIE. (MSIE didnt like the the way prototype.js deals with CR LF) > BTW, why do you require JS? The python interpreter comunicates back and forth via a widget just like gmail XD. Sorry for that. Anyway we stil need volunteers... http://cern.ch/test-iq Thanks! J. On Nov 12, 10:35 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Sun, 11 Nov 2007 13:33:09 -0300, <[EMAIL PROTECTED]> escribi?: > > >it seems the problem you guys found appears... > >when combining Windows OS and MSIE... > >(apologies... m_._m ) > > Or any other OS+browser with javascript disabled. > BTW, why do you require JS? Looks like it should be possible to do it with > just HTTP POST and plain old forms... > > > Dont know how to fix it .(I am a begginer...) > > if some soul wanna help out... the code is here... > >http://test-iq.web.cern.ch/test-iq/piton_is_easy.tar > > > Anyway it works fine with firefox :) > > The HTML code is invalid, so it works "fine" just by accident. > > -- > Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: display messages in python shell
Hi Kou,
I use this in http://cern.ch/test-volunteers...
to redirect error messages... \etc
hope it helps
#!/usr/bin/python
import os
import cgi
import safeeval
import sys
import string
import time
import re
import urllib
class PitonEsFacilException(Exception):
"Base class for all Exception of the python es facil code"
pass
class LanguageDoesNotExistException(PitonEsFacilException):
"Exception raised in case the received 'lang' parameter is non of
'en' or 'es'"
def __init__(self, lang):
self.lang=lang
class WritableObject:
def __init__(self):
self.content = ""
def write(self, string):
#self.content.append(string)
self.content = self.content + string
def display_error(str):
print "%s" % str
sys.exit(0)
def display_syntax_error(e,plang):
if (plang=="es_pi"):
eerr = e.text.replace("\n","")
langdict = init_dictionary("en->es")
for key in langdict:
eerr = eerr.replace(key, langdict[key])
print("ERROR SINTACTICO")
print("Revise la linea %s" % e.lineno)
print(" %s " % eerr)
elif (plang=="en_pi"):
eerr = e.text.replace("\n","")
langdict = init_dictionary("en->es en_pi")
for key in langdict:
eerr = eerr.replace(key, langdict[key])
print("SYNTAX ERROR")
print("Chec kline %s" % e.lineno)
print(" %s " % eerr)
elif (plang=="en_py"):
print("SYNTAX ERROR")
print("Check line %s" % e.lineno)
print(" %s " % e.text.replace("\n",""))
else:
raise LanguageDoesNotExistException(lang)
print(string.rjust("^",e.offset+3))
return e.text
def display_name_error(e,plang):
saveout = sys.stdout
foo = WritableObject()# a writable object
sys.stdout = foo
print e
sys.stdout = saveout
eerr = foo.content
if (plang=="es_pi"):
langdict = init_dictionary("en->es")
for key in langdict:
eerr = eerr.replace(key, langdict[key])
print "ERROR DE NOMRE: "+ eerr
elif (plang=="en_pi"):
langdict = init_dictionary("en->es en_pi")
for key in langdict:
eerr = eerr.replace(key, langdict[key])
print "NAME ERROR: "+ eerr
elif (plang=="en_py"):
print "NAME ERROR: " + eerr
else:
raise LanguageDoesNotExistException(lang)
return foo.content
def add_trial(form, outcome):
email = form["email"].value
code = form["code"].value
now = time.time()
logrecord = email + ","
logrecord += str(now) + ","
logrecord += time.strftime("%Y/%m/%d %H:%M:%S %Z",
time.localtime(now)) + ","
logrecord += str(outcome) + "\n"
#logrecord += str(output_window) + ","
#logrecord += str(code_window) + "\n"
f=open("log/trials.log", "a")
f.write(logrecord)
f.close()
def main():
print "Content-type: text/html\n\n"
form = cgi.FieldStorage()
# print form.keys()
code = form["code"].value
lang = form["lang"].value
plang = form["plang"].value
outcome="nodef"
output="nodef"
if (plang=="es_pi" or plang =="en_pi"):
langdict = init_dictionary("es->en")
for key in langdict:
code = code.replace(key, langdict[key])
if code.count("\r\n") > 0:
code = code.replace("\r\n","\n")
try:
safeeval.safe_eval(code)
saveout = sys.stdout
# example with redirection of sys.stdout
foo = WritableObject()# a writable object
sys.stdout = foo
safeeval.safe_eval(code)
output = foo.content
sys.stdout = saveout
except SyntaxError,e:
output = display_syntax_error(e,plang)
outcome = "XS"
except NameError,e:
output = display_name_error(e,plang)
outcome = "XN"
outcome = outcome + "," + urllib.quote(output) + "," +
urllib.quote(code)
add_trial(form,outcome)
def init_dictionary(lang):
if lang == "es->en":
mydict = {'imprime ':'print ','para_cada ':'for ','si ':'if
','en ': 'in ','sino:': 'else:','longitud(':'len('}
return mydict
elif lang == "en->es":
mydict = {'is not defined':'no esta
definido','name':'nombre','print ':'imprime ','for ':'para_cada ','if
':'si ','in ': 'en ','else:': 'sino:','len': 'longitud('}
return mydict
elif lang == "en->es en_pi":
mydict = {'print ':'imprime ','for ':'para_cada ','if ':'si
','in ': 'en ','else:': 'sino:','len': 'longitud('}
return mydict
raise LanguageDoesNotExistException(lang)
if __name__ == "__main__":
sys.stderr = sys.stdout
try:
main()
except KeyError,e:
display_error("Parameter not found in the HTTP request")
except LanguageDoesNotExistException, e:
display_error("\"lang\" parameter with value '%s' is not
allowed" % e.lang)
except safeeval.SafeEvalException:
display_error("SafeEvalError, This is a place ho
duck typing at will
Duck typing is called that way because "If it looks like a duck and
quacks like a duck, it must be a duck." I think it would be good to
have also "If the programmer wants to deal with it like a duck, it
must be a duck"
I mean, some tasks are rather boring in python when compared with php,
for example, let's imagine we have a dictionary that contains
dictionaries that contain the times that a key appears. We, or at
least I, would like to write something as short as:
dict[k1][k2] += 1
However we will have to do a longer code (this is the smallest code I
could come up with):
dict = {}
if not k1 in dict:
dict[k1] = {}
if not k2 in dict[k1]:
dict[k1][k2] = 0
dict[k1][k2] += 1
I know it is not the Apocalypse nor something really important when
compared with other things, but maybe it would be better if it wasn't
necessary to declare the variables when they are built-in types or to
initialize the keys in a dictionary, having special values (the
identity element of the operation that causes the initialization) to
initialize when it has not been done, initializing with the most
general type that supports the operation that causes the
initialization, casting to other type if necessary after that.
This is just an idea, maybe I'm not the first one suggesting it, or
maybe it is completely impossible to implement it because it would
require deep changes in python, but I wanted to discuss it.
Best regards.
--
http://mail.python.org/mailman/listinfo/python-list
Re: How to Delete a Cookie?
> c["mycook"]["expires"] = 0
Set ["expires"] using the following format to any time less than
current (which causes the browser to delete the cookie).
Here's a function I use to return a cookie expiry timestamp, negative
values passed in result in cookie being deleted.
def cookie_expiry_date(numdays):
""" Returns a cookie expiry date in the required format. -ve
value in = kill cookie.
`expires` should be a string in the format "Wdy, DD-Mon-YY
HH:MM:SS GMT"
NOTE! Must use [expires] because earlier IE versions don't
support [max-age].
"""
from datetime import date, timedelta
new = date.today() + timedelta(days = numdays)
return new.strftime("%a, %d-%b-%Y 23:59:59 GMT")
Usage:
c["mycook"]["expires"] = cookie_expiry_date(-10) # any negative value
will remove cookie
HTH,
JC
--
http://mail.python.org/mailman/listinfo/python-list
Re: How to Delete a Cookie?
On Jan 8, 10:33 am, [email protected] wrote: > On Jan 8, 1:16 pm, Jose C wrote: > > > > > > c["mycook"]["expires"] = 0 > > > Set ["expires"] using the following format to any time less than > > current (which causes the browser to delete the cookie). > > Here's a function I use to return a cookie expiry timestamp, negative > > values passed in result in cookie being deleted. > > > def cookie_expiry_date(numdays): > > """ Returns a cookie expiry date in the required format. -ve > > value in = kill cookie. > > `expires` should be a string in the format "Wdy, DD-Mon-YY > > HH:MM:SS GMT" > > NOTE! Must use [expires] because earlier IE versions don't > > support [max-age]. > > """ > > from datetime import date, timedelta > > new = date.today() + timedelta(days = numdays) > > return new.strftime("%a, %d-%b-%Y 23:59:59 GMT") > > > Usage: > > c["mycook"]["expires"] = cookie_expiry_date(-10) # any negative value > > will remove cookie > > > HTH, > > JC > > Jose C's piece of code works to delete the cookie as does setting > ["expires"]=0 but ONLY as long as I also set the path. Why is this? The path specifies which directory the cookie is active. Usually the path is set to /, which means the cookie is valid throughout the entire domain, but you could set it to /mydir meaning it would only be active for pages within /mydir. > So what would be the best way to do this. I tried reading in the > existing cookie (b), creating a new cookie (c) with all the same > values except for the "expires" but this did not get my cookie > deleted. To kill the cookie, simply set a cookie with the same name (and path) and a past date (or 0, although IIRC there was some issue with 0 being used on a particular browser some time ago, can't remember which on at the moment) as an 'expires' parameter, is enough to tell the browser to kill an existing cookie with that same name, regardles of it's value or previous expiry, etc. Basically, when you set a cookie, the browser overwrites the previous one of the same name if it exists. If not, it creates a new cookie with your specified parameters. So in your case, when you want to kill the cookie you set previously, you should be able to just set a cookie of the exact same name, path and 'expire' it appropriately, and the browser takes care of the rest. Don't worry about assigning it's previous value, the browser is just going to delete it anyway. JC -- http://mail.python.org/mailman/listinfo/python-list
Re: How to Delete a Cookie?
> To kill the cookie, simply set a cookie with the same name (and path) Actually you may not even need to specify the path. Just the name and expires param should do the trick. Haven't played with cookies in a while so try with and without the path. -- http://mail.python.org/mailman/listinfo/python-list
Python is cool!!
I have been learning Python, and it is amazing I am using the tutorial that comes with the official distribution. At the end my goal is to develop applied mathematic in engineering applications to be published on the Web, specially on app. oriented to simulations and control systems, I was about to start learning Java but I found Python which seems easier to learn that Java. Would it be easy to integrate Python in Web pages with HTML? I have read many info on Internet saying it is, and I hope so Any opinion -- http://mail.python.org/mailman/listinfo/python-list
Re: PyGame migrating to JavaScript
On Apr 2, 3:19 am, Gary Herron wrote: > Xavier Ho wrote: > > Javascript in recent years has been getting better and better, and > > > now is a way better language than python. So to keep up with the > > times pygame has been rewritten for javascript. > > > *shudders* > > > Can someone convince me why that is a good idea at all? Any rationales? > > > Cheers, > > -Xav > > It's a joke -- seehttp://en.wikipedia.org/wiki/April_Fools%27_Day > > -- > Gary Herron, PhD. > Department of Computer Science > DigiPen Institute of Technology > (425) 895-4418 I read that on its web site and because I am not accustomed to that "April fools" I fell into the trap, I though “I am just starting to studying Python now they come with javaScript again”. :) I have recently learned JavaScript and I did not like it to much. BTW within my culture the equivalent to such Aprils Fools is the Innocents’ Days (on Dec 28th) which comes from the Christian History. -- http://mail.python.org/mailman/listinfo/python-list
Problem with two instances of PySerial
Hello friends,I am developing an application to read data from serial port and display it on the screen using GUI developed in pyQT. For this I have instantiated the GUI as well as pySerial objects in the main thread. I have provided a button 'Read' which when clicked by the user reads from the serial port using read() method of pySerial. However, for debugging purposes I also want to poll the serial port continuously for arrival of data and display on screen. I achieve this by creating a separate worker thread to poll the serial port for arrival of data and then updating the required widget in main thread of program. For polling the serial port, I create a separate instance of pySerial object. However, I am unable to read any data in the worker thread. Can the reason for this be 2 instances of pySerial objects being connected to serial port. The reason I had this doubt was because Serial.Connect() in the worker thread did not throw any exception & isOpen() method returns true. I request you to help me in figuring out the problem. -- Regards, Shine Jose -- http://mail.python.org/mailman/listinfo/python-list
Re: using identifiers before they are defined
You should define the function first and then call it. def something(i): return i a = something(5) If you want a reference to the function somewhere else you can do this: global alias = something print alias(i) On Tue, Jun 12, 2012 at 1:53 PM, Julio Sergio wrote: > I'm puzzled with the following example, which is intended to be a part of a > module, say "tst.py": > > a = something(5) > > def something(i): > return i > > > > When I try: > > ->>> import tst > > The interpreter cries out: > > Traceback (most recent call last): > File "", line 1, in > File "tst.py", line 11, in >a = something(5) > NameError: name 'something' is not defined > > I know that changing the order of the definitions will work, however there > are > situations in which referring to an identifier before it is defined is > necessary, e.g., in crossed recursion. > > So I modified my module: > > global something > > a = something(5) > > > def something(i): > return i > > > And this was the answer I got from the interpreter: > > ->>> import tst > > Traceback (most recent call last): > File "", line 1, in > File "tst.py", line 12, in >a = something(5) > NameError: global name 'something' is not defined > > > Do you have any comments? > > Thanks, > > --Sergio. > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Re: using identifiers before they are defined
Seems like what you need is from othermodule import bb def aa(): bb() On Tue, Jun 12, 2012 at 2:51 PM, Ethan Furman wrote: > Julio Sergio wrote: > >> Jose H. Martinez gmail.com> writes: >> >> >>> You should define the function first and then call it. >>> >>> >>> def something(i): return i >>> >>> >>> a = something(5) >>> >>> >>> If you want a reference to the function somewhere else you can do this: >>> >>> >> I know that. That was what I meant by "changing the order of the >> definitions will work" in my original message. >> >> And I insist in the issue, which is not trivial... In my message I >> mentioned "crossed recursion", and I delve into it here: >> >> Suppose I have to define two functions, aa, and, bb that are designed to >> call each other: >> >> def aa(): >> ... >> ... a call of bb() somewhere in the body of aa >> ... >> >> def bb(): >> ... >> ... a call of aa() somewhere in the body of bb >> ... >> >> >> Whatever the order of definition of aa and bb the problem remains >> > > No. The reply from MRAB explains this. > > ~Ethan~ > -- > http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list> > -- http://mail.python.org/mailman/listinfo/python-list
Re: string to list
string.split(',') will give you an array.
Example:
'AAA,",,",EEE,FFF,GGG '.split(',')
['AAA', '"', '', '"', 'EEE', 'FFF', 'GGG']
On Wed, Jun 13, 2012 at 10:53 PM, Chris Rebert wrote:
> n Wed, Jun 13, 2012 at 7:29 PM, bruce g wrote:
> > What is the best way to parse a CSV string to a list?
>
> Use the `csv` module:
> http://docs.python.org/library/csv.html
> http://www.doughellmann.com/PyMOTW/csv/
>
> The `StringIO` module can be used to wrap your string as a file-like
> object for consumption by the `csv` module:
> http://docs.python.org/library/stringio.html
>
> Cheers,
> Chris
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
http://mail.python.org/mailman/listinfo/python-list
Re: lazy evaluation of a variable
Another option would be to refactor your function so that it is a generator expression using the yield keyword. On Sun, Jun 17, 2012 at 7:40 PM, Peter Otten <[email protected]> wrote: > Gelonida N wrote: > > > I'm having a module, which should lazily evaluate one of it's variables. > > Meaning that it is evaluated only if anybody tries to use this variable. > > > > At the moment I don't know how to do this and do therefore following: > > > > > > ### mymodule.py ### > > var = None > > > > def get_var(): > > global var > > if var is not None: > > return var > > var = something_time_consuming() > > > > > > > > Now the importing code would look like > > > > import mymodule > > def f(): > > var = mymodule.get_var() > > > > The disadvantage is, that I had to change existing code directly > > accessing the variable. > > > > > > I wondered if there were any way to change mymodule.py such, that the > > importing code could just access a variable and the lazy evaluation > > would happen transparently. > > > > import mymodule > > def f(): > > var = mymodule.var > > > > > > > > Thanks in advance for you suggestions > > You can inject arbitrary objects into sys.modules: > > >>> import sys > >>> class MyModule(object): > ... def __init__(self): > ... self._var = None > ... @property > ... def var(self): > ... result = self._var > ... if result is None: > ... print "calculating..." > ... self._var = result = 42 > ... return result > ... > >>> sys.modules["mymodule"] = MyModule() > >>> import mymodule > >>> mymodule.var > calculating... > 42 > >>> mymodule.var > 42 > > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
Changing the original SQLite version to the latest
Greetings. I have tried both Cygwin and SQLite support, and I have received very little ideas from them, so I am trying this to see if anyone has dealt with such a problem before. If I use Cygwin setup tool and install python39 and thus, $ python Python 3.9.10 (main, Jan 20 2022, 21:37:52) [GCC 11.2.0] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> import sqlite3 >>> sqlite3.sqlite_version '3.34.0' >>> As you can see, the SQlite3 version installed is v3.34.0. Right now, the version available is 3.40.1. What I would like to do is to work with the latest SQLite version. I have 4 Cygwin instances, 2 of them are working ok, 2 are not. This is what I have done to get python to use 3.41.0: - downloaded the latest SQlite check-in from the site - $ tar -xvf SQLite-44200596.tar.gz - cd to SQLite-44200596 - $ ./configure --prefix=/usr - $ make install These steps above have worked on two PCs, but I don't know what is the difference that makes the other two work, and the other two not work. I have started a few instances of Cygwin on the PC that is not working, and I have been trying for a few days, and I am humbling myself, and asking for help. So, the request is to get python3 to change the SQLite3 library from 3.34.0 to 3.41.0. Any help would be greatly appreciated. Since this is Windows 10, it's probably some SQLite DLL somewhere that is being pulled instead of the one installed. Perhaps some of you can provide a few suggestions to see where I can find a solution. I know the next step is to compile python, but, I rather try to find how to fix this and get to the bottom of it. Thanks, thanks and thanks. josé -- What if eternity is real? H... -- https://mail.python.org/mailman/listinfo/python-list
Re: Changing the original SQLite version to the latest
On Tue, Feb 14, 2023 at 8:55 PM Thomas Passin wrote: > > As a point of reference, the Python installation I've got on my Windows > box (not a cygwin install) is > > Python 3.10.9 (tags/v3.10.9:1dd9be6, Dec 6 2022, 20:01:21) [MSC v.1934 > 64 bit (AMD64)] on win32 > > and the sqlite_version is 3.39.4 Thanks, previous to v3.40.1, the released version was v.3.39.4. I wish it was that one that one. :-) -- What if eternity is real? H... -- https://mail.python.org/mailman/listinfo/python-list
Re: Changing the original SQLite version to the latest
On Tue, Feb 14, 2023 at 8:55 PM Thomas Passin wrote:
>
> On 2/14/2023 3:30 PM, jose isaias cabrera wrote:
> > Greetings.
> >
> > I have tried both Cygwin and SQLite support, and I have received very
> > little ideas from them, so I am trying this to see if anyone has dealt
> > with such a problem before.
> >
> > If I use Cygwin setup tool and install python39 and thus,
> >
> > $ python
> > Python 3.9.10 (main, Jan 20 2022, 21:37:52) [GCC 11.2.0] on cygwin
> > Type "help", "copyright", "credits" or "license" for more information.
> >>>> import sqlite3
> >>>> sqlite3.sqlite_version
> > '3.34.0'
> >>>>
> >
> > As you can see, the SQlite3 version installed is v3.34.0. Right now,
> > the version available is 3.40.1. What I would like to do is to work
> > with the latest SQLite version. I have 4 Cygwin instances, 2 of them
> > are working ok, 2 are not. This is what I have done to get python to
> > use 3.41.0:
> > - downloaded the latest SQlite check-in from the site
> > - $ tar -xvf SQLite-44200596.tar.gz
> > - cd to SQLite-44200596
> > - $ ./configure --prefix=/usr
> > - $ make install
> >
> > These steps above have worked on two PCs, but I don't know what is the
> > difference that makes the other two work, and the other two not work.
> > I have started a few instances of Cygwin on the PC that is not
> > working, and I have been trying for a few days, and I am humbling
> > myself, and asking for help. So, the request is to get python3 to
> > change the SQLite3 library from 3.34.0 to 3.41.0. Any help would be
> > greatly appreciated. Since this is Windows 10, it's probably some
> > SQLite DLL somewhere that is being pulled instead of the one
> > installed. Perhaps some of you can provide a few suggestions to see
> > where I can find a solution. I know the next step is to compile
> > python, but, I rather try to find how to fix this and get to the
> > bottom of it. Thanks, thanks and thanks.
>
> As a point of reference, the Python installation I've got on my Windows
> box (not a cygwin install) is
>
> Python 3.10.9 (tags/v3.10.9:1dd9be6, Dec 6 2022, 20:01:21) [MSC v.1934
> 64 bit (AMD64)] on win32
>
> and the sqlite_version is 3.39.4
In case anyone needs the answer, These steps worked for me:
In case anyone needs the answer, what worked for me was:
-- Downloaded the Pre-release Snapshots
$ wget https://sqlite.org/snapshot/sqlite-snapshot-202302131932.tar.gz
-- untared the snapshot
$ tar xvf sqlite-snapshot-202302131932.tar.gz
-- cd to the untared directory
$ cd sqlite-snapshot-202302131932
$ ./configure --prefix=/usr
$ make install
And this process has set the python SQLite version to the
sqlite-snapshot version. After that, you can download the trunk and
follow the same procedure, and the version of the trunk will be
changed also.
$ ./SQLiteVersion.py
3.41.0
['/usr/lib/python3.9/sqlite3']
3.41.0
2023-02-13 19:32:40
ecdeef43b27412b0b0b09e09a62ad3a03836a3fc80f2070268090e7ca8f02712
I hope this helps.
This script may be useful...
$ cat SQLiteVersion.py
#!/usr/bin/python3
import sqlite3
def ConnectToSharedDB(sdb):
return sqlite3.connect(sdb)
print(sqlite3.sqlite_version)
print(sqlite3.__path__)
SharedDB = ":memory:"
con = ConnectToSharedDB(SharedDB)
cur = con.cursor()
cur.execute("SELECT sqlite_version(),sqlite_source_id();")
for row in cur:
print(row[0] + '\r\n' + row[1])
con.close()
--
What if eternity is real? Where will you spend it? H...
--
https://mail.python.org/mailman/listinfo/python-list
Regular Expression bug?
Greetings. For the RegExp Gurus, consider the following python3 code: import re s = "pn=align upgrade sd=2023-02-" ro = re.compile(r"pn=(.+) ") r0=ro.match(s) >>> print(r0.group(1)) align upgrade This is wrong. It should be 'align' because the group only goes up-to the space. Thoughts? Thanks. josé -- What if eternity is real? Where will you spend it? H... -- https://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression bug?
On Thu, Mar 2, 2023 at 2:32 PM <[email protected]> wrote: > > On 2023-03-02 at 14:22:41 -0500, > jose isaias cabrera wrote: > > > For the RegExp Gurus, consider the following python3 code: > > > > import re > > s = "pn=align upgrade sd=2023-02-" > > ro = re.compile(r"pn=(.+) ") > > r0=ro.match(s) > > >>> print(r0.group(1)) > > align upgrade > > > > > > This is wrong. It should be 'align' because the group only goes up-to > > the space. Thoughts? Thanks. > > The bug is in your regular expression; the plus modifier is greedy. > > If you want to match up to the first space, then you'll need something > like [^ ] (i.e., everything that isn't a space) instead of that dot. Thanks. I appreciate your wisdom. josé -- What if eternity is real? Where will you spend it? H... -- https://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression bug?
On Thu, Mar 2, 2023 at 2:38 PM Mats Wichmann wrote: > > On 3/2/23 12:28, Chris Angelico wrote: > > On Fri, 3 Mar 2023 at 06:24, jose isaias cabrera wrote: > >> > >> Greetings. > >> > >> For the RegExp Gurus, consider the following python3 code: > >> > >> import re > >> s = "pn=align upgrade sd=2023-02-" > >> ro = re.compile(r"pn=(.+) ") > >> r0=ro.match(s) > >>>>> print(r0.group(1)) > >> align upgrade > >> > >> > >> This is wrong. It should be 'align' because the group only goes up-to > >> the space. Thoughts? Thanks. > >> > > > > Not a bug. Find the longest possible match that fits this; as long as > > you can find a space immediately after it, everything in between goes > > into the .+ part. > > > > If you want to exclude spaces, either use [^ ]+ or .+?. > > https://docs.python.org/3/howto/regex.html#greedy-versus-non-greedy This re is a bit different than the one I am used. So, I am trying to match everything after 'pn=': import re s = "pm=jose pn=2017" m0 = r"pn=(.+)" r0 = re.compile(m0) s0 = r0.match(s) >>> print(s0) None Any help is appreciated. -- https://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression bug?
On Thu, Mar 2, 2023 at 8:30 PM Cameron Simpson wrote: > > On 02Mar2023 20:06, jose isaias cabrera wrote: > >This re is a bit different than the one I am used. So, I am trying to > >match > >everything after 'pn=': > > > >import re > >s = "pm=jose pn=2017" > >m0 = r"pn=(.+)" > >r0 = re.compile(m0) > >s0 = r0.match(s) > > `match()` matches at the start of the string. You want r0.search(s). > - Cameron Simpson Thanks. Darn it! I knew it was something simple. -- What if eternity is real? Where will you spend it? H... -- https://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression bug?
On Thu, Mar 2, 2023 at 8:35 PM wrote: > > It is a well-known fact, Jose, that GIGO. > > The letters "n" and "m" are not interchangeable. Your pattern fails because > you have "pn" in one place and "pm" in the other. It is not GIGO. pm=project manager. pn=project name. I needed search() rather than match(). > > >>> s = "pn=jose pn=2017" > ... > >>> s0 = r0.match(s) > >>> s0 > > > > > -Original Message- > From: Python-list On > Behalf Of jose isaias cabrera > Sent: Thursday, March 2, 2023 8:07 PM > To: Mats Wichmann > Cc: [email protected] > Subject: Re: Regular Expression bug? > > On Thu, Mar 2, 2023 at 2:38 PM Mats Wichmann wrote: > > > > On 3/2/23 12:28, Chris Angelico wrote: > > > On Fri, 3 Mar 2023 at 06:24, jose isaias cabrera > wrote: > > >> > > >> Greetings. > > >> > > >> For the RegExp Gurus, consider the following python3 code: > > >> > > >> import re > > >> s = "pn=align upgrade sd=2023-02-" > > >> ro = re.compile(r"pn=(.+) ") > > >> r0=ro.match(s) > > >>>>> print(r0.group(1)) > > >> align upgrade > > >> > > >> > > >> This is wrong. It should be 'align' because the group only goes up-to > > >> the space. Thoughts? Thanks. > > >> > > > > > > Not a bug. Find the longest possible match that fits this; as long as > > > you can find a space immediately after it, everything in between goes > > > into the .+ part. > > > > > > If you want to exclude spaces, either use [^ ]+ or .+?. > > > > https://docs.python.org/3/howto/regex.html#greedy-versus-non-greedy > > This re is a bit different than the one I am used. So, I am trying to match > everything after 'pn=': > > import re > s = "pm=jose pn=2017" > m0 = r"pn=(.+)" > r0 = re.compile(m0) > s0 = r0.match(s) > >>> print(s0) > None > > Any help is appreciated. > -- > https://mail.python.org/mailman/listinfo/python-list > -- What if eternity is real? Where will you spend it? H... -- https://mail.python.org/mailman/listinfo/python-list
Re: Regular Expression bug?
On Thu, Mar 2, 2023 at 9:56 PM Alan Bawden wrote: > > jose isaias cabrera writes: > >On Thu, Mar 2, 2023 at 2:38 PM Mats Wichmann wrote: > >This re is a bit different than the one I am used. So, I am trying to match >everything after 'pn=': > >import re >s = "pm=jose pn=2017" >m0 = r"pn=(.+)" >r0 = re.compile(m0) >s0 = r0.match(s) >>>> print(s0) >None > > Assuming that you were expecting to match "pn=2017", then you probably > don't want the 'match' method. Read its documentation. Then read the > documentation for the _other_ methods that a Pattern supports. Then you > will be enlightened. Yes. I need search. Thanks. -- What if eternity is real? Where will you spend it? H... -- https://mail.python.org/mailman/listinfo/python-list
Java Integer.ParseInt translation to python
Greetings! I've looked through the internet (not long, though) but I have not been able to find a python translation to buffer[0] = (byte)Integer.parseInt(string,16); Has anyone ported any java programs to python and has translated this? any help would be greatly appreciated. thanks. josé -- http://mail.python.org/mailman/listinfo/python-list
Re: Java Integer.ParseInt translation to python
Yes, that's my problem. I don't want to go through the java stuff. :-) Thanks. - Original Message - From: "Bill Mill" <[EMAIL PROTECTED]> To: "jose isaias cabrera" <[EMAIL PROTECTED]> Cc: Sent: Monday, January 31, 2005 7:28 PM Subject: Re: Java Integer.ParseInt translation to python Jose, On Mon, 31 Jan 2005 19:23:35 -0500, jose isaias cabrera <[EMAIL PROTECTED]> wrote: Greetings! I've looked through the internet (not long, though) but I have not been able to find a python translation to buffer[0] = (byte)Integer.parseInt(string,16); Tell me what this does, give me an example or two, and I'll translate it for you. I don't feel like going to read the java docs to figure it out. You probably want to look at the built-in int() function though. Type help(int) at the python prompt. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Java Integer.ParseInt translation to python
thanks everyone...! - Original Message - From: "ech0" <[EMAIL PROTECTED]> Newsgroups: comp.lang.python To: Sent: Monday, January 31, 2005 7:27 PM Subject: Re: Java Integer.ParseInt translation to python buffer[0] = int(string,16) & 0xff that should work -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Java Integer.ParseInt translation to python
Ok, so this,
buffer[0] = (byte)Integer.parseInt(string,16);
in java is, partly, this
buffer[0] = int(string, 16)
in python. But here is my problem. When I call this java subroutine,
byte[] decodeKey(String inString)
{
if (inString == null)
return null;
System.out.println("StringLength = " + inString.length());
byte[] retBuf = new byte[inString.length()/2];
// The string has two hex characters per byte.
for (int index = 0; index < retBuf.length; index++)
{
System.out.print(inString.substring(2*index, 2*index+2));
System.out.println(" " +
Integer.parseInt(inString.substring(2*index, 2*index+2), 16) + " " +
(byte)Integer.parseInt(inString.substring(2*index, 2*index+2), 16));
retBuf[index] =
(byte)Integer.parseInt(inString.substring(2*index, 2*index+2), 16);
}
System.out.println(retBuf);
return retBuf;
}
I get this output:
StringLength = 40
c1 193 -63
7c 124 124
e1 225 -31
86 134 -122
ab 171 -85
94 148 -108
ee 238 -18
b0 176 -80
de 222 -34
8a 138 -118
e3 227 -29
b5 181 -75
b7 183 -73
51 81 81
a7 167 -89
c4 196 -60
d8 216 -40
e9 233 -23
ed 237 -19
eb 235 -21
[EMAIL PROTECTED]
But, here is what I have for python,
def PrepareHash(HashStr):
while len(HashStr) > 0:
byte = HashStr[0:2]
print byte,int(byte,16),byte(int(byte,16)) # & 0xff
HashStr = HashStr[2:]
return byte
def Main():
HashStr = "c17ce186ab94eeb0de8ae3b5b751a7c4d8e9edeb"
HashStr = PrepareHash(HashStr)
print "Prepared HashStr :",HashStr
Main()
and it results to,
mulo 19:32:06-> python test.py
c1 193 Á
7c 124 |
e1 225 á
86 134
ab 171 «
94 148
ee 238 î
b0 176 °
de 222 Þ
8a 138
e3 227 ã
b5 181 µ
b7 183 ·
51 81 Q
a7 167 §
c4 196 Ä
d8 216 Ø
e9 233 é
ed 237 í
eb 235 ë
which is not even close, and yes, I know that it's not the same code. So,
the question is, how can I make this java (byte) call in python? so that the
result would be the right one, "[EMAIL PROTECTED]"
Thanks.
josé
--
http://mail.python.org/mailman/listinfo/python-list
Problem with sockets and python 2.5
I had two programs, server.py and client.py(attached) 1: server.py at i386 python 2.4 client.py at x86_64 python 2.5 Work 2: server.py at x86_64 python 2.5 client.py at i386 python 2.4 Don't work Any ideas? Thanks. Jose Alberto clinet.py Description: application/python server.py Description: application/python -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with sockets and python 2.5
El Lunes, 19 de Marzo de 2007, Jose Alberto Reguero escribió: > I had two programs, server.py and client.py(attached) > > 1: > server.py at i386 python 2.4 > client.py at x86_64 python 2.5 > Work > > 2: > server.py at x86_64 python 2.5 > client.py at i386 python 2.4 > Don't work > > Any ideas? > Thanks. > > Jose Alberto The problem was with kernel 2.6.21-rc4. I put kernel 2.6.20.3 and the programs work well. Thanks. Jose Alberto -- http://mail.python.org/mailman/listinfo/python-list
Variables and their domain
Hi all, I have one doubt, in my applciation I have a method (Method1) which has other method (Method2) inside of it. Ok, in my first method I define a variable "lista" which is an array, an other one, "lb", which is a listbox with some elements inserted from lista. Then, when I do a double click on a lb element, I go to Method 2, where I can continue inserting elements in lb and reading lista, but if I do "lista=..." I get an error of local variable referenced. The problem is that if I do lb and lista global variables, I have to declare them outside any method, haven't I?. If someone could help me I would be very pleased. Resume: Main Method1 Lista=a,b,c,d. Lb=listbox Method2 Lista=e,f,g.. -->error! Thanks in advance Best Regars, Naxo -- http://mail.python.org/mailman/listinfo/python-list
Send file in base64
Hi all,
I need to send a file to a server using xmlrpc api. The receiver must get
file data in base64 type, and what I do is:
openfilename=tkFileDialog.askopenfilename(filetypes=[("all files", "*")])
f=open(tlocald.get(),'r')
functionsend(xmlrpclib.Binary(f), f.name)
And what I get is, at least:
base64.encode(StringIO.StringIO(self.data), out)
TypeError: expected a character buffer object
But if I do:
openfilename=tkFileDialog.askopenfilename(filetypes=[("all files", "*")])
f=open(tlocald.get(),'r')
g=f.read()
functionsend(xmlrpclib.Binary(g), f.name)
It apparently works, but what I send becomes totally understanding, it is
like if I send only a bit part of the file.
Anyone who could help me?
Thanks in advance
Best regards,
___
José Ignacio Gisbert Sanus
--
http://mail.python.org/mailman/listinfo/python-list
RV: Receiving messages blocks all :-(
First, sorry for sending this mail to this list, I know this is off-topic,
but xmpppy-devel mailing list is out of work :-( If someone uses xmpppy,
please try to answer me, or at least give me a more adequate mailing list,
please. Thank you.
-
Hi all,
I am a newby in xmppy, and I want to make a very simple messaging jabber
client. As I read from different tutorials, it seems very easy, in fact, I
can send messages to other jabber clients from my poor application, but
the problem appears when I try to receive messages. I do more or less what
Sebastian Moors explains in his xmpppy: a practical guide, i.e (code
fragment):
def StepOn(conn):
try:
conn.Process(1)
except KeyboardInterrupt:
return 0
return 1
def GoOn(conn):
while StepOn(conn):
pass
cl=xmpp.Client(jid.getDomain(),debug=[])
cl.connect()
cl.auth(jid.getNode(),jidparams['password'])
cl.sendInitPresence()
cl.RegisterHandler('message',messageCB)
cl.RegisterHandler('presence',presenceCB)
GoOn(cl)
But when my application enters in GoOn loop, it completely freezes (I have
to shut down it by force). Anyone knows why or knows another solution for
receiving messages?, Im using Windows but I dont think it is the problem.
Thanks in advance, best regards,
___
José Ignacio Gisbert Sanus
--
http://mail.python.org/mailman/listinfo/python-list
xmlrpclib.binary to a file doubt
Hi all,
I have a problem in my application which uses xml-rpc methods. From one hand
I can send a file to a server doing
f=open(Myfile,'rb')
g=f.read()
name=(f.name).split("/")
name=name[len(name)-1]
calltosendmethod(xmlrpclib.Binary(g),name)
And it works fine. But on the other hand I have to get a document from the
server, which method returns document content in xmlrpclib.binary format,
and I am not able to store it on a local file. If somebody knows how to,
please tell me something, anything will helps.
Thanks in advance,
___
José Ignacio Gisbert Sanus
--
http://mail.python.org/mailman/listinfo/python-list
RE: xmlrpclib.binary to a file doubt
I have resolved my problem!, I think it is easy for everyone, but I unknown data binary object attribute. So, code for store a file that is passed as a binary object would be: file = calltoreceivemethod() placetostore=open(filename,'wb') data=file.data placetostore.write(data) Regards, Naxo _ De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] En nombre de Jose Ignacio Gisbert Enviado el: miércoles, 12 de diciembre de 2007 9:12 Para: [email protected] Asunto: xmlrpclib.binary to a file doubt Hi all, I have a problem in my application which uses xml-rpc methods. From one hand I can send a file to a server doing f=open(Myfile,'rb') g=f.read() name=(f.name).split("/") name=name[len(name)-1] calltosendmethod(xmlrpclib.Binary(g),name) And it works fine. But on the other hand I have to get a document from the server, which method returns document content in xmlrpclib.binary format, and I am not able to store it on a local file. If somebody knows how to, please tell me something, anything will helps. Thanks in advance, ___ José Ignacio Gisbert Sanus -- http://mail.python.org/mailman/listinfo/python-list
RE: *SPAM*: 04.0/4.0 - Re: how to maximize a Tkinter Window in python TK???
If you want to start with your main window maximized, you can do:
root = Tk()
root.state("zoomed")
Regards,
Naxo
-Mensaje original-
De: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] En
nombre de Matimus
Enviado el: jueves, 13 de diciembre de 2007 2:18
Para: [email protected]
Asunto: *SPAM*: 04.0/4.0 - Re: how to maximize a Tkinter Window in python
TK???
On Dec 12, 3:11 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> hello @ all,
>
> subj?
example:
import Tkinter as tk
rt = tk.Tk()
rt.state("zoomed")
rt.overrideredirect(True)
can = tk.Canvas(rt, bg="black",borderwidth=0,highlightthickness=0)
can.pack(expand=True, fill=tk.BOTH)
def draw_rect(e):
can.create_rectangle(e.x,e.y,e.x+100,e.y+100, fill='white',
outline='white')
can.bind("",draw_rect)
rt.bind("",lambda e:rt.destroy())
rt.mainloop()
-Matt
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list
Manually installing PIL
Hello All, Does somebody install PIL manually??, I mean, copy directories manually without executing setup.py. I saw an identical message from Guirai, but I didn't see any response. Thanks in advance! Best Regards, Naxo -- http://mail.python.org/mailman/listinfo/python-list
Read header and data from a binary file
Hello,
I want to read from a binary file called myaudio.dat
Then I've tried the next code:
import struct
name = "myaudio.dat"
f = open(name,'rb')
f.seek(0)
chain = "< 4s 4s I 4s I 20s I I i 4s I 67s s 4s I"
s = f.read(4*1+4*1+4*1+4*1+4*1+20*1+4*1+4*1+4*1+4*1+4*1+67*1+1+4*1+4*1)
a = struct.unpack(chain, s)
header = {'identifier' : a[0],
'cid' : a[1],
'clength' : a[2],
'hident' : a[3],
'hcid32' : a[4],
'hdate' : a[5],
'sampling' : a[6],
'length_B' : a[7],
'max_cA' : a[8],
'max_cA1' : a[9],
'identNOTE' : a[10],
'c2len' : a[11],}
It produces:
{'length_B': 150001, 'sampling': 5, 'max_cA1': 'NOTE', 'hident': 'HEDR',
'c2len': "Normal Sustained Vowel 'A', Voice and Speech Lab., MEEI, Boston,
MA", 'hdate': 'Jul 13 11:57:41 1994', 'identNOTE': 68, 'max_cA': -44076,
'cid': 'DS16', 'hcid32': 32, 'identifier': 'FORM', 'clength': 300126}
So far when I run f.tell()
>>f.tell()
136L
The audio data length is 300126, now I need a clue to build an array with
the audio data (The Chunk SDA_), would it possible with struct?, any help ?
Thanks
The file format is:
Offset | Length | Type |Contents
0 4character Identifier: "FORM"
4 4character Chunk identifier: "DS16"
8 4integer Chunk length
12 - - Chunk data
Header 2
Offset Length Type Contents
0 4 character Identifier: "HEDR" or "HDR8"
4 4 integer Chunk length (32)
8 20 character Date, e.g. "May 26 23:57:43 1995"
28 4 integer Sampling rate
32 4 integer Data length (bytes)
36 2 unsigned integer Maximum absolute value for channel A:
0x if not defined
38 2 unsigned integer Maximum absolute value for channel A:
0x if not defined
NOTE Chunk
Offset Length Type Contents
0 4 character Identifier: "NOTE"
4 4 integer Chunk length
8 - character Comment string
SDA_, SD_A or SDAB Chunk
Offset Length Type Contents
0 4 character Identifier: "SDA_", "SD_B", or "SDAB"
4 4 integer Chunk length
8 - - Data
--
http://mail.python.org/mailman/listinfo/python-list
Read header and data from a binary file [LONG]
Hello,
I want to read from a binary file called myaudio.dat
Then I've tried the next code:
import struct
name = "myaudio.dat"
f = open(name,'rb')
f.seek(0)
chain = "< 4s 4s I 4s I 20s I I i 4s I 67s s 4s I"
s = f.read(4*1+4*1+4*1+4*1+4*1+20*1+4*1+4*1+4*1+4*1+4*1+67*1+1+4*1+4*1)
a = struct.unpack(chain, s)
header = {'identifier' : a[0],
'cid' : a[1],
'clength' : a[2],
'hident' : a[3],
'hcid32' : a[4],
'hdate' : a[5],
'sampling' : a[6],
'length_B' : a[7],
'max_cA' : a[8],
'max_cA1' : a[9],
'identNOTE' : a[10],
'c2len' : a[11],}
It produces:
{'length_B': 150001, 'sampling': 5, 'max_cA1': 'NOTE', 'hident': 'HEDR',
'c2len': "Normal Sustained Vowel 'A', Voice and Speech Lab., MEEI, Boston,
MA", 'hdate': 'Jul 13 11:57:41 1994', 'identNOTE': 68, 'max_cA': -44076,
'cid': 'DS16', 'hcid32': 32, 'identifier': 'FORM', 'clength': 300126}
So far when I run f.tell()
>>f.tell()
136L
The audio data length is 300126, now I need a clue to build an array with
the audio data (The Chunk SDA_), would it possible with struct?, any help ?
Thanks
The file format is:
Offset | Length | Type |Contents
0 4character Identifier: "FORM"
4 4character Chunk identifier: "DS16"
8 4integer Chunk length
12 - - Chunk data
Header 2
Offset Length Type Contents
0 4 character Identifier: "HEDR" or "HDR8"
4 4 integer Chunk length (32)
8 20 character Date, e.g. "May 26 23:57:43 1995"
28 4 integer Sampling rate
32 4 integer Data length (bytes)
36 2 unsigned integer Maximum absolute value for channel A:
0x if not defined
38 2 unsigned integer Maximum absolute value for channel A:
0x if not defined
NOTE Chunk
Offset Length Type Contents
0 4 character Identifier: "NOTE"
4 4 integer Chunk length
8 - character Comment string
SDA_, SD_A or SDAB Chunk
Offset Length Type Contents
0 4 character Identifier: "SDA_", "SD_B", or "SDAB"
4 4 integer Chunk length
8 - - Data
--
http://mail.python.org/mailman/listinfo/python-list
Fwd: Inconveniente
*Buenas tardes, le escribo breve y puntualmente para reportar este el siguiente error al cual no le pude dar solución.* *Instalé Python 3.9.1 (64 bits), todo había funcionado bien hasta que necesité usar la librería seaborn. Al ejecutar mi algoritmo obtenía el siguiente error: * (...\Python\Python39\site-packages\matplotlib\__init__.py) * Desinstalé python, lo reinstalé. * Instale diversas versiones de Matpltlib * Desinstalé seaborn, lo reinstalé. Busque soluciones en la página oficial, foros como:Stack Overflow, reddit, etc y no pudé dar con la solución para esta versión de python. Al final instalé python 3.8 de 32 bits, con las librerías que necesitaba, y logré realizar el trabajó. Mi OS es Windows 10, 64 bits. Sin más por el momento, me despido cordialmente. -- https://mail.python.org/mailman/listinfo/python-list
PDF count pages
Hi there, Does anyone know how I could do in order to get/count the number of pages of a PDF file? (from python of course ;) ) Thanks beforehand. Cheers, Jose -- Jose Benito Gonzalez Lopez CERN Document Server ** <http://cds.cern.ch/> ** InDiCo Project ** <http://indico.cern.ch> ** CDSconv ** <http://cdsconv.cern.ch> Room: Bldg 513-R-027 ** Voice: +41 22 76 78893 -- http://mail.python.org/mailman/listinfo/python-list
Another SimpleXMLRPCServer question.
Let's hope this is my last question on the matter. I'm implementing a SimpleXMLRPCServer, and last week I had a problem John helped me solve. The thing is that my server is to be called from a remote machine, so when declaring the instance, the line ("localhost", 8000) wouldn't work because it would only listen on
127.0.0.1.
Next thing I tried was the line ('', 8000) (two simple quotes). That way it worked just fine, because now the server listens on all interfaces.
My question now is: is this the way SimpleXMLRPCServers are implemented? All the examples I've found use the simple quotes, without providing any other aditional examples. I want to know if there are any security risks that raise from the fact that it listens on all interfaces. I haven't been able to find any information on this. If you need more info regarding my question, please ask.
Thank you very much in advance.
Jose Carlos.
--
http://mail.python.org/mailman/listinfo/python-list
Working with files in a SimpleXMLRPCServver
I'm setting up a server accepting XML-RPC calls using the SimpleXMLRPCServer class. Basically, what I have to do is send a zip-compressed file to the server, have the server unzip it and process it, after processing it the server is supposed to zip the file again, and send it back to the client.
I found a solution, but wanted to ask you if you think there's an easier way of doing this.
What I do at the client first is to compress the file (which is a .txt) using os.system("zip blah blah.txt"). Then I obtain the name of the compressed file (let's assume it is blah.zip). Once I have the name of the zip file, I do the following:
fd = open("blah.zip", 'r')bin = xmlrpclib.Binary(fd.read())
server.process(bin)
I obtain a file descriptor, read the data and stuff it in a Binary object, and send it to the server as a parameter to the process method.
Then, at the server script, I create a file, and write into it the data contained in that Binary object using the attribute .data. That way I'll have a new file with the data passed to the server. Then again I use os.system
(...) to unzip the data and recover the original content.
When I need to send content back to the client, the whole process is repeated.
My question is: do you think this is an appropiate way to exchange files between client and server? I'm relativately new to Python, and the task of the file exchange has been assigned to me. I haven't been able to find documentation on the subject, so any help would be appreciated.
If you need any more information about what I'm trying to do, just ask.
Thank you so much for your attention :)
--
http://mail.python.org/mailman/listinfo/python-list
Re: Working with files in a SimpleXMLRPCServer
Oops, I'm afraid I replied to Brian only instead of to the whole distribution list. I copy the message I sent to him so that everyone can read it:I'm afraid I cannot use the zlib library provided by Python, since the ZIP files I'm supposed to send must be password-protected, and I haven't been able to find a method in the library that let me zip a file with a password. I could be wrong though... As for the HTTP server instead of the XML-RPC one... you are totally right. However, in the specification I was handled to perform my task, it said explicitely to use the XML-RPC protocol; maybe it has to do because there is also some data-bases issues in our application, and using XML-RPC would be more appropiate. For example, the text file I'm supposed to zip has its information extracted from a database table. Anyway, since those are the constraints I'm facing, I thought handling the files issue the way I did would be more appropiate. Since I have never done network programming till now, I'm having difficulties dealing with it, and I want to know if the solution I chose is acceptable. Thank you very much.Cheers, -- http://mail.python.org/mailman/listinfo/python-list
Sending a file to a remote server.
Hi. I posted a message in the list a couple of days ago about sending a file to a remote SimpleXMLRPCServer. Well. my doubt still remains, so I come to you again in search of a clearer answer.The thing is I want to send a ZIP file to a server, and what I basically do is enclose the file data into a Binary object by doing something like "data = ""
f.read())". Then I call a function in the server, passing the object as a parameter, and have the server process the same file by doing something likef = open("somefile.zip", 'w')f.write(binaryObject.data
)Since I've never programmed server/client before, I've never faced the fact of sending a file to a remote machine.I just want to know if what I've done to send the file is acceptable, and if you know of a better way to send files to a SimpleXMLRPCServer.
Thank you very much for your attention.
--
http://mail.python.org/mailman/listinfo/python-list
Problem connecting Python with PostgreSQL
Hello. I have a problem connecting to a PostgreSQL database and I don't know where the problem lays. A bit of background: I installed the psycopg module yesterday (it was a bit of a pain to do it since I installed the wrong version and it didn't work). I got to install it in the end anyway. I have a database hosted in a server (let's call it xxx.yy.com). I need to access that database from another computer. I have configured the PostgreSQL server right (except something I'll explain later), and added the right line to the pg_hba.conf file. After trying to connect to the server using the connect() function in the psycopg module, I get the following error message after a few seconds: "psycopg.OperationalError: could not connect to server: Connection timed out Is the server running on host xxx.yy.com and accepting TCP/IP connections on port 5432?" Following the error's suggestion, I went to check the Postgresql.conf file, and realized the "tcpip_socket = true" line was commented. I uncommented the line, and after restarting the server, it crashed, so I commented the line again. I thought that was the source of the problem, but when I checked my netstat, realized that the postgresql server was listening on port 5432... Don't ask me why, since the line "tcpip_socket = true" was commented. But why does the server crash when I try to set tcpip_socket to true? Anyway, I'm now out of possible solutions. Maybe the source of the error lays in a different place. I really need help on this. Has anyone ever gotten the same error message before, or is familiar with it? If you need more information about the error, I'll be glad to share it with you. Thank you very much for your attention. Jose Carlos. -- http://mail.python.org/mailman/listinfo/python-list
Handling IP addresses with SimpleXMLRPCServer.
Hello. I' m trying to use the client's IP address in a method defined inside the SimpleXMLRPCServer. Up till now I'm able to verify that the client's IP is an authorised one (I do this before calling the _dispatch method). I can redefine the _dispatch method extending the SimpleXMLRPCHandler class, and do something like if (self.client_address[0] not in [list of IPs]) raise self.UnknownIP, "Unknown IP address" else *inserts SimpleXMLRPCHandler's _dispatch code in here* This works just fine, but I need to do something else. I need to have the IP address within the called method to know who's the client calling the method, and act in cosequence. There are 4 possible clients who will be requesting data from the server, and I need to check woh's actually requesting them via IP. Is there any way to handle the client's IP inside a method in the server? Thank you very much in advance for your help. Jose Carlos. -- http://mail.python.org/mailman/listinfo/python-list
Converting Integer to String
Hello. I'm trying to turn an integer into a string, and the "repr" function doesn't work the way I want. The repr function inserts a '\n' at the end of the string, and I need to get the string representation without the '\n', since I need to insert the stringed data into a sql query. I get "SELECT * FROM blah WHERE(code = 23\n)" I need to get rid of that "\n". Is there any other function I can use to turn an integer into a string without the \n at the end? Thanks for your attention. Jose Carlos. -- http://mail.python.org/mailman/listinfo/python-list
Re: Converting Integer to String
Thank you for the quick reply, but still doesn't work. Now it seems the "\n" is executed instead of printed. This is what I get when I print the query: SELECT * FROM blah WHERE (cod = 23 ) The code is being executed in an XMLRPC server. Maybe that's the problem? I don't know, but I don't get the \n when I execute str or repr in the python command shell. It's weird... 2006/4/6, Wesley Brooks <[EMAIL PROTECTED]>: Jose Carlos,str(234) gives '234'Is that what your after?Wesley. On 06/04/06, Jose Carlos Balderas Alberico < [EMAIL PROTECTED]> wrote: Hello. I'm trying to turn an integer into a string, and the "repr" function doesn't work the way I want. The repr function inserts a '\n' at the end of the string, and I need to get the string representation without the '\n', since I need to insert the stringed data into a sql query. I get "SELECT * FROM blah WHERE(code = 23\n)" I need to get rid of that "\n". Is there any other function I can use to turn an integer into a string without the \n at the end? Thanks for your attention. Jose Carlos.--http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Converting Integer to String
That works just fine.Problem solved :) Thank you so much for your help Wesley Jose Carlos. 2006/4/6, Wesley Brooks <[EMAIL PROTECTED]>: ...or'%i' %546gives:'546' Wesley Brooks. On 06/04/06, Wesley Brooks <[EMAIL PROTECTED] > wrote: Jose Carlos,str(234) gives '234'Is that what your after?Wesley. On 06/04/06, Jose Carlos Balderas Alberico < [EMAIL PROTECTED]> wrote: Hello. I'm trying to turn an integer into a string, and the "repr" function doesn't work the way I want. The repr function inserts a '\n' at the end of the string, and I need to get the string representation without the '\n', since I need to insert the stringed data into a sql query. I get "SELECT * FROM blah WHERE(code = 23\n)" I need to get rid of that "\n". Is there any other function I can use to turn an integer into a string without the \n at the end? Thanks for your attention. Jose Carlos.--http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Beginner question. Exceptions
Hello. I'm having my way with exceptions in a little program I've done, and I'm wondering... What is a decent way of dealing with them? By a decent way I mean, what should I do when I see that an exception has occurred? I've seen that Python's default action is to print a stack trace. As far as I know, exception handling is a mean of knowing what can go wrong with your program, like anticipating wrongs and treating them. What I'm having trouble understanding is this: if I use a "raise" sentence to raise an exception... shoul I use it inside a "try" block, so I can catch it with an "except" block? If I don't do that, a stack trace will be printed onto the screen... Is that the way it's usually done? Please, help me out, for I'm kind of new to exceptions and I want to know if I get them right. Thanks a lot in advance. Jose Carlos. -- http://mail.python.org/mailman/listinfo/python-list
Can't connect to SimpleXMLRPCServer. Help needed.
Up till now I've been setting up my server and client in the same machine, using the "localhost" address for everything.
Once I've made it work, I need to move my client application to the computer where it'll be run from, and for some reason, I get a socket.error: (111, 'connection refused').
The server is listening on port 8000. I've used the line
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8000), )
##register functions...
...
...
server.serve_forever()
And the client does the following:
host = ":8000" (where is the server's IP address)
conn = xmlrpclib.connect(host)
data = "" (requestData is a function previously registered in the server)
I've made sure the server is listening on port 8000, since the netstat command says it's listening on port 8000.
I've also pinged the server from the client and viceversa and I get an answer. So they can see each other.
I've tried looking in google but couldn't find a solution to this problem. Anyone can give me a hand on this?
Thank you very much.
Jose Carlos.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Can't connect to SimpleXMLRPCServer. Help needed.
Thank you for the quick reply John...
Is there a way to sort this out? Should I specify another address here:
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8000), )
instead of "localhost" ?
I'm kind of new to client/server programming, so I'm at a loss here.
Thank you very much for your attention.
Jose Carlos.
2006/4/12, John Abel <[EMAIL PROTECTED]>:
Your server is only listening on 127.0.0.1.Jose Carlos Balderas Alberico wrote:
> Up till now I've been setting up my server and client in the same> machine, using the "localhost" address for everything.> Once I've made it work, I need to move my client application to the
> computer where it'll be run from, and for some reason, I get a> socket.error: (111, 'connection refused').>> The server is listening on port 8000. I've used the line>> server =
SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8000), )> ##register functions...> ...> ...> server.serve_forever()>>> And the client does the following:
>> host = ":8000" (where is the server's IP address)> conn = xmlrpclib.connect(host)> data = "" (requestData is a function previously> registered in the server)
>> I've made sure the server is listening on port 8000, since the netstat> command says it's listening on port 8000.> I've also pinged the server from the client and viceversa and I get an> answer. So they can see each other.
>> I've tried looking in google but couldn't find a solution to this> problem. Anyone can give me a hand on this?> Thank you very much.>> Jose Carlos.
--
http://mail.python.org/mailman/listinfo/python-list
Re: Can't connect to SimpleXMLRPCServer. Help needed.
Okay, I changed this:
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8000), )
for this:
server = SimpleXMLRPCServer.SimpleXMLRPCServer(('', 8000), )
Replacing "localhost" with two simple quotes ' makes it work.
Anyone knows the reason for this?
Thank so much.
Jose Carlos
2006/4/12, Jose Carlos Balderas Alberico <[EMAIL PROTECTED]>:
Thank you for the quick reply John...
Is there a way to sort this out? Should I specify another address here:
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8000), )
instead of "localhost" ?
I'm kind of new to client/server programming, so I'm at a loss here.
Thank you very much for your attention.
Jose Carlos.
2006/4/12, John Abel <[EMAIL PROTECTED]>:
Your server is only listening on
127.0.0.1.Jose Carlos Balderas Alberico wrote: > Up till now I've been setting up my server and client in the same> machine, using the "localhost" address for everything.> Once I've made it work, I need to move my client application to the
> computer where it'll be run from, and for some reason, I get a> socket.error: (111, 'connection refused').>> The server is listening on port 8000. I've used the line>> server =
SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8000), )> ##register functions...> ...> ...> server.serve_forever()>>> And the client does the following:
>> host = ":8000" (where is the server's IP address)> conn = xmlrpclib.connect(host)> data = "" (requestData is a function previously> registered in the server)
>> I've made sure the server is listening on port 8000, since the netstat> command says it's listening on port 8000.> I've also pinged the server from the client and viceversa and I get an> answer. So they can see each other.
>> I've tried looking in google but couldn't find a solution to this> problem. Anyone can give me a hand on this?> Thank you very much.>> Jose Carlos.
--
http://mail.python.org/mailman/listinfo/python-list
Help with movie module
Hi, I'm sorry by my bad english. I have a little problem with pygame.movie module when I try work whit him show this problem [josean...@qumax reproductor]$ python packbox.py packbox.py:64: RuntimeWarning: use mixer: No module named mixer (ImportError: No module named mixer) pygame.mixer.quit() Traceback (most recent call last): File "packbox.py", line 98, in main() File "packbox.py", line 95, in main publicidad_show(screen) File "packbox.py", line 64, in publicidad_show pygame.mixer.quit() File "/usr/lib/python2.6/site-packages/pygame/__init__.py", line 70, in __getattr__ raise NotImplementedError(MissingPygameModule) NotImplementedError: mixer module not available (ImportError: No module named mixer) anybody help me please, I'm search in the web and I found this email list. thanks José angel -- http://mail.python.org/mailman/listinfo/python-list
[Python-announce] Benchmark Smil vs Scikit-image (morphological features)
Hello, We've done a comparative benchmark (speed and memory usage) with Smil and Scikit-Image. Smil is a mathematical morphology dedicated library of functions. So comparisons are done only on this area. We've been working on Mathematical Morphology for more than 50 years now the discipline was created here at our research department in the sixties. Smil inherits the experience of previous libraries and software we've been writing since the 70's. In just some few words, Smil can be orders of magnitude faster than Scikit-image (hundreds or even thousands) on some operations thanks to parallelization and vectorization (SIMD), depending on the computer architecture. Smil doesn't replace scikit-image but may be a good complement to scikit-image when speed is important. Benchmark results are available at : https://smil.cmm.minesparis.psl.eu/smil-vs-skimage Comments are welcome, Best regards José-Marcio -- --- Jose Marcio MARTINS DA CRUZ, Ph.D. Ecole des Mines de Paris Centre de Morphologie Mathématique https://orcid.org/-0002-2981-7028 --- Mon livre sur le spam : http://amzn.to/LEscRu --- -- https://mail.python.org/mailman/listinfo/python-list
ANN: Smil 0.9.1
Hi all, I'm pleased to announce Smil - Simple Morphological Image Library - v. 0.9.1 SMIL is a library with all basic and some advanced mathematical morphology features which can be extended with plugins and user modules. It's been developed in C++ and has a Python interface thanks to Swig. It's a product of CMM, the research Center of Mathematical Morphology of Mines-Paristech. The discipline of Mathematical Morphology was created here in the 60's by Jean Serra and Georges Matheron. We use Smil in our research activities in the field. Smil is distributed with GPL license. You can find Smil - binaries and documentation - at our web site : http://smil.cmm.mines-paristech.fr or the source code at : https://github.com/ensmp-cmm/smil Thanks -- --- Jose Marcio MARTINS DA CRUZ, Ph.D. Ecole des Mines de Paris Centre de Morphologie Mathématique --- Spam :http://amzn.to/LEscRu ou http://bit.ly/SpamJM --- -- https://mail.python.org/mailman/listinfo/python-list
Fw: Python installation problem
En Mar, 31 Marzo, 2020 en 18:48, yo escribió: Para: [email protected] I installed the Python software , but I could not find the python.exe file with the Unscramble software What do you advise ? Regards -- https://mail.python.org/mailman/listinfo/python-list
