The pydoc.html.docmodule sends a page with clickable links relative to the
script location. Is there a way to tell pydoc to prepend a string to those URLs?
-- Gnarlie
--
http://mail.python.org/mailman/listinfo/python-list
Hello. What I want to do is delete every dictionary key/value of the name
'Favicon' regardless of depth in subdicts, of which there are many. What is the
best way to do it?
-- Gnarlie
--
http://mail.python.org/mailman/listinfo/python-list
This problem is solved, I am so proud of myself for figuring it out! After
reading some of these ideas I discovered the plist is really lists underneath
any "Children" key:
from plistlib import readPlist
def explicate(listDicts):
for dict in listDicts:
if 'FavIcon' in d
On Tuesday, December 18, 2012 3:31:41 AM UTC-7, Hans Mulder wrote:
> On 18/12/12 06:30:48, Gnarlodious wrote:
>
> > This problem is solved, I am so proud of myself for figuring it out!
>
> > After reading some of these ideas I discovered the plist is really
>
> >
Error: AttributeError: 'module' object has no attribute '_strptime'
This problem is driving me crazy. It only happens in Python 3.3.0, while on my
server running 3.1.3 it behaves as expected. When I try to access
time.strptime() it errors with
AttributeError: 'module' object has no attribute '_
Thanks for the help.
This error only occurs on my devbox which is running Py 3.3.0:
print(time.__file__, file=sys.stderr)
/usr/local/python-3.3.0/frameworks/Python.framework/Versions/3.3/lib/python3.3/lib-dynload/time.so
which looks normal to me.
The server box, which is running Py 3.1.3, says t
Nick Cash wrote:
> I was able to work around this by simply importing _strptime myself at server
> startup time.
THANK YOU! That fixed it, I simply put
import _strptime
in my *.wsgi script. It feels like a kludgy solution, but it works.
I should also mention that I had a similar problem with
Chris Angelico wrote:
> The problem here is that Python
> doesn't have any magical way to deal with messy imports in
> multiple threads
But couldn't Py 3.3.1 at least raise an error mentioning threading as a
possible cause? Because "No module named _strptime" is pretty cryptic.
-- Gnarlie
--
Graham Dumpleton has informed me that the the relevant bug reports are:
http://bugs.python.org/issue8098
http://bugs.python.org/issue9260
To quote:
All the problems derive from a stupid function in Python internals called
PyImport_ImportModuleNoBlock(). It was designed to avoid lockups of the i
Thank you for a reasonable discussion of the problem, although I don't really
understand what you said. This is a WSGI webapp configured for one-process and
one-thread.
I can imagine my unorthodox handling of imported modules is suspect. To
explain, my webapp first loads modules from a dict of
After copious headscratching I took Ned's advice and went for 3.2
which includes built-in interactive arrow key support. To any Mac OSX
readers, save yourself the trouble and don't even try Python 3.1.3.
-- Gnarlie
http://Gnarlodious.com
--
http://mail.python.org/mailman/listinfo/python-list
SI escaped characters from output for
CGI rendering?
-- Gnarlodious
--
http://mail.python.org/mailman/listinfo/python-list
Thanks, it looks like the appropriate incantation is:
import pydoc
pydoc.html.docmodule(sys.modules[__name__])
-- Gnarlie
--
http://mail.python.org/mailman/listinfo/python-list
Say I send a request like this:
http://0.0.0.0/Sectrum/Gnomon?see=Gnomon&order=7&epoch=1303541219
This makes for a CGIform of the CGI Tuple Object type:
FieldStorage(None, None, [MiniFieldStorage('see', 'Gnomon'),
MiniFieldStorage('order', '7'), MiniFieldStorage('epoch',
'1303541219.58')])
So the
Is there any way to call a Py script from Javascript in a webpage?
I don't have to tell you how messy JS is…
-- Gnarlie
--
http://mail.python.org/mailman/listinfo/python-list
What is the easiest way to get the first number as boolean?
divmod(99.6, 30.1)
Or do I have to say:
flote, rem=divmod(99.6, 30.1)
bool(flote)
-- Gnarlie
--
http://mail.python.org/mailman/listinfo/python-list
Is there a way to declare a project-wide variable and use that in all
downstream modules?
-- Gnarlir
--
http://mail.python.org/mailman/listinfo/python-list
On Jun 23, 7:59 am, Noah Hall wrote:
> >>>from a import x
I'm doing that:
import Module.Data as Data
However I end up doing it in every submodule, so it seems a little
redundant. I wish I could load the variable in the parent program and
have it be available in all submodules. Am I missing someth
On Jun 23, 8:42 am, Peter Otten wrote:
> from Module import Data
>
> There, you saved three more characters .
OK I get it, LOL.
> But I don't think it's a good idea. Remember that "explicit is better than
> implicit".
Thanks, now I know what that means.
-- Gnarlie
--
http://mail.python.org/mail
On Jun 23, 11:42 am, Noah Hall wrote:
> > What about using an environment variable?
>
> Yes, that's fine, but only if the data is suitable for it.
In this case, the variable is a namespace containing the property of a
folder full of plist files. I access any dictionary item anywhere in
my webapp
On Jun 23, 12:10 pm, Terry Reedy wrote:
> from test import ftest,itest
>
> def test_main():
>
> if __name__ == '__main__':
> test_main()
I don't understand this. Can you explain, or refer me to some
documentation?
-- Gnarlie
http://Gnarlodious.com
--
http://mail.python.org/mailman/listinf
Let me restate my question.
Say I have a script Executable.py that calls all other scripts and
controls them:
#!/usr/local/bin/python
from Module import Data
import ModuleTest
ModuleTest.py has this:
print(Data.Plist.Structure)
Running Executable.py gives me this:
NameError: name 'Data' is not
Idea: It occurs to me that my application class inherits "object". Can
I set that to inherit an object that already includes data? So every
subsequent class would start off with data loaded (except for class
Data).
Seems like it should already be invented.
-- Gnarlie
--
http://mail.python.org/ma
On Jun 24, 12:27 am, Terry Reedy wrote:
> > 1) Can I tell Executable.py to share Data with ModuleTest.py?
>
> After the import is complete, yes.
> import ModuleTest
> ModuleTest.Data = Data
>
> This works if the use of Data is inside a function that is not called
> during import, not if the use of
Using introspection, is there a way to get a list of "property
getters"?
Does this:
vars=property(getVars(), "Dump a string of variables and values")
have some parsable feature that makes it different from other
functions? Or would I need to use some naming scheme to parse them
out?
-- Gnarlie
On Jul 6, 3:35 am, Christian Heimes wrote:
Thank you! Exactly what I wanted.
-- Gnarlie
http://Gnarlodious.com
--
http://mail.python.org/mailman/listinfo/python-list
Question. Is there a special method or easy way to set default values
with each call to an instance? Any ideas to make it easier? What I
want to do is have a constantly updating set of values which can be
overridden. Just thought there was an easy way to set that up.
-- Gnarlie
--
http://mail.pyt
On Jul 12, 8:46 am, Alister Ware wrote:
> I thought that was the role of the __init__ function
>
> class Something:
> def __init__(self):
> self.value="some value"
OK, that sets a value at init time. But is there a similar built-in to
run whenever the class instance is ca
On Jul 12, 6:44 pm, Steven D'Aprano wrote:
> All the words are in English, but the sentences make no sense :)
LOL, impressive powers of mind-reading! Exactly what I needed:
import time
class Event:
epoch=time.time()
def doSomething(self, epoch=None):
if epoch is None:
I get a construct like this:
form=FieldStorage(None, None, [MiniFieldStorage('name1', 'Val1'),
MiniFieldStorage('name2', 'Val2'), MiniFieldStorage('name3', 'Val3')])
Now how would I assign every variable name* its value?
lI did try locals().update(form) however I get
>>> name2
-> MiniFieldStorag
I get a construct like this:
form=FieldStorage(None, None, [MiniFieldStorage('name1', 'Val1'),
MiniFieldStorage('name2', 'Val2'), MiniFieldStorage('name3', 'Val3')])
Now how would I assign every variable name* its value?
lI did try locals().update(form) however I get
>>> name2
-> MiniFieldStorag
I should add that this does what I want, but something a little more
Pythonic?
import cgi, os
os.environ["QUERY_STRING"] = "name1=Val1&name2=Val2&name3=Val3"
form=cgi.FieldStorage()
form
dict = {}
for key in form.keys(): dict[ key ] = form[ key ].value
dict
locals().update(dict)
name3
-- Gnarl
I should add that this does what I want, but something a little more
Pythonic?
import cgi, os
os.environ["QUERY_STRING"] = "name1=Val1&name2=Val2&name3=Val3"
form=cgi.FieldStorage()
form
dict = {}
for key in form.keys(): dict[ key ] = form[ key ].value
dict
locals().update(dict)
name3
-- Gnarl
On Aug 17, 3:25 am, Chris Angelico wrote:
> You do NOT
> want end users having the power to set variables.
Thanks for the warning, I can see I will need to quarantine the form
input. And update() is out of the question.
-- Gnarlie
http://Gnarlodious.com/
--
http://mail.python.org/mailman/listinfo
In my last post I learned of the necessity of filtering CGI input, so
what I want to do is set a dict of allowable variable names:
allowedVariables = {'eeny':None, 'meeny':None, 'miny':None, 'mo':None}
# Set up a FieldStorage object:
import cgi
inputVariables = cgi.FieldStorage()
for name, value
On Aug 22, 9:39 am, Miki Tebeka wrote:
> HTH
Yes it helps, thank you!
-- Gnarlie
http://Gnarlodious.com
--
http://mail.python.org/mailman/listinfo/python-list
Using the doctest module, I get three different outputs:
1) From the Terminal shell, I see a full report:
python ~/Sites/Sectrum/Filter.py -v
2) From the Terminal interactive session, I see an abbreviated report
of only the failures:
from doctest import testmod; testmod(Filter)
3) From a browser
Yeah, I just spent about 2 hours trying everything I could think of...
without success. Including your suggestions. Guess I'll have to skip
it. But thanks for the ideas.
-- Gnarlie
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 28, Peter Otten wrote:
> Are you using Python 2.x? Then you cannot redefine print. Instead you have
> to redirect stdout. The following example should run as a cgi script:
>
> #!/usr/bin/env python
> import cgi
> import sys
> from cStringIO import StringIO
...
That works! Except for Py3 I
RSS script runs fine on my dev machine but errors on the server
machine. Script was last run 3 days ago with no problem. Possible
clue: dev machine is (Mac OSX) running Python 3.1.1 while server is
running Python 3.1.3. I have not updated anything that should suddenly
cause this error starting yest
On Mar 30, 9:28 am, Peter Otten wrote:
> You are trying to run your 3.x code with Python 2.x...
You're right. Exactly why this started happening I don't know.
Thanks.
-- Gnarlie
--
http://mail.python.org/mailman/listinfo/python-list
I'm running a shell command like:
plutil -convert xml1 "~/Library/Preferences/iCab/iCab 4 Bookmarks"
Getting error:
~/Library/Preferences/iCab/iCab 4 Bookmarks: Permission denied
How would I capture this error using a method of subprocess?
I read the doc at
http://docs.python.org/release/3.0.1/l
OK I get it, and that seems like it should work. But when I simulate a
permissions error by setting the file to unwritable I get an error:
outdata, errdata = process.communicate()
Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.1/li
I get it, you instantiate an object, call a method and get a tuple in
response. However, here is what I see:
>>> process.communicate()
(b'~/Library/Preferences/iCab/iCab 4 Bookmarks: Permission denied\n',
b'')
So all I get is the string and no error message, which is the same
thing I get with the
On Apr 2, 9:29 pm, Chris Rebert wrote:
> if proc.returncode: # non-zero exit status, indicating error
> print("Encountered error:")
> print(error_output) # output the error message
>
Like in my previous post, this only outputs an empty string.
Apparently plutil doesn't communicate well.
On Apr 5, 6:42 am, neil wrote:
> what are the advantages? if it wasn't for python 3 breaking backwards
> compatibility would it be the better choice?
I adopted Py3 because of support of OrderedDict and many new features.
Since mine was a new project using no existing libraries, it made
sense.
--
Not a Python question. You should go over to
http://groups.google.com/group/comp.sys.mac.system/ and ask.
-- Gnarlie
--
http://mail.python.org/mailman/listinfo/python-list
I have an SQLite query that returns a list of tuples:
[('0A',), ('1B',), ('2C',), ('3D',),...
What is the most Pythonic way to loop through the list returning a
list like this?:
['0A', '1B', '2C', '3D',...
-- Gnarlie
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 25, 9:42 pm, CM wrote:
> flat_list = [item[0] for item in returned_list]
HA! So easy. Thanks.
-- Gnarlie
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 25, 10:59 pm, Steven D'Aprano wrote:
> In Python 3, map becomes lazy and returns an iterator instead of a list,
> so you have to wrap it in a call to list().
Ah, thanks for that tip. Also works for outputting a tuple:
list_of_tuples=[('0A',), ('1B',), ('2C',), ('3D',)]
#WRONG:
(x for (x,)
My scripting has grown to the point where the Apache server is a
problem. My Python websites run and quit, which means I need to save
data and recreate everything next page load. Bulky and slow. What is
the simplest solution?
I am running Py3 on OSX Server with Apache 2. Essentially I want
certain
I installed Python 3.2, suddenly getting an error on my sqlite pages
(CGI):
ProgrammingError: Cannot operate on a closed cursor
Works normally in interactive mode. Seems to error when the sqlite
statement is in a function. Are sqlite objects now required to be
declared global?
-- Gnarlie
--
htt
It turns out Python 3.2 now honors closing sqlite connections opened
in another module. Previous versions allowed you to have identically
named sqlite connections open in other modules. Python 3.2 apparently
treats them all as the same connection.
Hopefully some other victim will find this, becaus
Can someone please explain what I am doing wrong?
Calling script:
from Gnomon import GnomonBase
Gnomon=GnomonBase(3)
Called script:
class GnomonBase(object):
def __init__(self, bench):
# do stuff
But all I get is:
TypeError: __init__() takes exactly 1 positional argument (2 given)
I don't have a trace because I am using mod_wsgi under Apache. Maybe
there is a way to debug using mod_wsgi but I haven't been able to
figure out how.
My problem is that in order to run mod_wsgi I had to downgrade to
Python 3.1.3 which may be causing the problem. This website was
running fine in P
Well, I have a whole lot of scripts where I could say something like
this:
def __init__(self, var1, var2, var3...):
Now suddenly I have to change them all to run in Python 3.1.3?
This is apparently not a bug. And I rebooted still getting the same
behavior.
Can someone explain it?
-- Gnarlie
--
Thanks for all the help, this looks like a bug in mod_wsgi. I tried it
interactively under Py3.1.3 and it behaves normally. I'll take this
over to the mod_wsgi group.
-- Gnarlie
http://Gnarlodious.com
--
http://mail.python.org/mailman/listinfo/python-list
I updated Python to 3.1.3 on Mac OSX. Now suddenly in the Interactive
interpreter I get all this instead of scrolling the history:
>>> ^[[A^[[A^[[A
What's wrong and how to fix it?
-- Gnarlie
http://Gnarlodious.com
--
http://mail.python.org/mailman/listinfo/python-list
Like so:
./configure MACOSX_DEPLOYMENT_TARGET=10.6 \
--enable-framework=/usr/local/python-3.1/frameworks \
--prefix=/usr/local/python-3.1 \
--enable-universalsdk=/ \
--with-universal-archs=intel
Is there some directive to enable Readline?
-- Gnarlie
http://Gnarlodious.com
--
http://mail.python.
What is the best way (Python 3) to loop through dict keys, examine the
string, change them if needed, and save the changes to the same dict?
So for input like this:
{'Mobile': 'string', 'context': '', 'order': '7',
'time': 'True'}
I want to booleanize 'True', turn '7' into an integer, escape
'',
On Oct 15, 5:53 pm, PoD wrote:
> data = {
> 'Mobile': 'string',
> 'context': '',
> 'order': '7',
> 'time': 'True'}
> types={'Mobile':str,'context':str,'order':int,'time':bool}
>
> for k,v in data.items():
> data[k] = types[k](v)
Thanks for the tip, I didn't know you could do
On Oct 16, 5:25 pm, Steven D'Aprano wrote:
> How do you sanitize user input?
Thanks for your concern. This is what I now have, which merely expands
each value into its usable type (unquotes them):
# filter each value
try:
var=int(var)
except ValueError:
if var in ('False', 'True'):
v
Steven: Thanks for those tips, I've implemented all of them. Also only
allowing whitelisted variable names. Feeling much more confident.
-- Gnarlie
--
http://mail.python.org/mailman/listinfo/python-list
Say this:
class tester():
_someList = [0, 1]
def __call__(self):
someList = self._someList
someList += "X"
return someList
test = tester()
But guess what, every call adds to the variable that I am trying to
copy each time:
test()
>
On Oct 22, 6:41 pm, Chris Rebert wrote:
> The line `someList = self._someList` does NOT copy the list. It make
> `someList` point to the same existing list object.
Thanks for all those explanations, I've already fixed it with a tuple.
Which is more reliable anyway.
-- Gnarlie
--
http://mail.pyt
Initializing a list of objects with one value:
class Order:
def __init__(self, ratio):
self.ratio=ratio
def __call__(self):
return self.ratio
ratio=[1, 2, 3, 4, 5]
Orders=[Order(x) for x in ratio]
But now I want to __init__ with 3 values:
class Order:
def __init__(self, ratio, bias, loc
On Oct 30, 9:15 am, Chris Angelico wrote:
> Orders=[Order(x,y,z) for x,y,z in zip(ratio, bias, locus)]
Brilliant, thanks!
-- Gnarlie
--
http://mail.python.org/mailman/listinfo/python-list
I want to assign a list of variables:
locus=[-2, 21, -10, 2, 12, -11, 0, 3]
updating a list of objects each value to its respective instance:
for order in range(len(Orders)):
Orders[order].locus=locus[order]
This works, even though it reads like doggerel. Is there a more
pythonesque way
On Nov 1, 3:33 pm, Terry Reedy wrote:
> > for obj, val in zip(Orders, locus):
> > obj.locus = val
>
> > I'm not sure how worthwhile it is converting the above to a list
> > comprehension (when the list would just be thrown away). Having said
> > that the call to zip creates an unnecessary list.
>
What I say is this:
def SaveEvents(self,events):
try:
plistlib.writePlist(events, self.path+'/Data/Events.plist') #
None if OK
except IOError:
return "IOError: [Errno 13] Apache can't write Events.plist
file"
Note that success returns"None" while failure returns a string.
I cat
On Nov 8, 3:16 pm, Steven D'Aprano wrote:
> content = Data.Dict.SaveEvents(Data.Plist.Events) or content
>
> This will leave content unchanged if no error is returned, otherwise it
> will replace the value.
Ah, the 'or' operator does it. Thank you, that is exactly what I was
looking for.
I should
What I am doing is importing modules that have an identical instance
name. So I say:
import Grid
Grid has its instance:
Grid.Grid()
and this is the same for all modules of my webapp.
allowedPages is a list of modules to import, so they are quoted
strings:
for page in self.allowedPages:
seta
To explain my reasoning, this scheme will allow me to run the script three
ways, as shell, as one-shot CGI or as a persistent mod_wsgi module.
So to be more exhaustive:
In __init__ I can say:
import Grid
self.Grid = Grid.Grid
self.Grid is now the instance of Grid inside the module Grid.
then
If you are writing your own scripts, I would recommend Py3 for learning. But if
you are studying existing scripts to learn, Py2 might be better.
I have been doing Python for about 2 years and started learning Py3 with no
regrets. Py2 is not going to be "obsolete" for quite a while. It is almost
HA! After much experimenting I hit upon getattr(__import__(page), page):
for page in self.allowedPages:
scriptPath = '{}/{}.py'.format(os.path.dirname(__file__), page)
if os.path.exists(scriptPath):
self.modules[page] = getattr(__import__(page), page)
Then in __call_ I just say:
tar
What is the best way to operate on a tuple of values transforming them against
a tuple of operations? Result can be a list or tuple:
tup=(35, '34', 0, 1, 31, 0, '既濟')
from cgi import escape
[tup[0], "{}".format(tup[1]), bool(tup[2]),
bool(tup[3]), tup[4], bool(tup[5]), escape(tup[6])]
-> [35,
Wow, that is so elegant. Python is awesome.
-- Gnarlie
--
http://mail.python.org/mailman/listinfo/python-list
Given a module's name, how do I get the file path without importing it?
Searched all over, can't find any such info.
Is it possible to ask if a named module exists before attempting an import?
Or are we forced to import first and catch any failure?
-- Gnarlie
--
http://mail.python.org/mailman/
Roy Smith wrote:
> import imp
> imp.find_module()
Oh yeah that works. I am getting a list of modtimes using List Comprehension,
from a list of modules, which will be compared to an older list to see if
mod_wsgi needs to be restarted.
Maybe thee is an easy way to get the modtimes, I'd be gratef
I am rolling my own, and learning Python at the same time.
One more question. Say I want to assemble a list of tuples like this:
modules = ['wsgiref', 'http']
import imp
[(imp.find_module(module)[1], os.path.getmtime(imp.find_module(module)[1])) for
module in modules]
Can I in some way assign i
Say I have a tuple I want to expand assigning to variables:
tup = *func()
var = tup[0]
lst.append(tup[1])
Or could I do it in one line?
var, lst.append() = *func()
So I want to append one variable to a list on the fly, is it possible?
-- Gnarlie
http://gnarlodious.com
--
http://mail.python.or
On Monday, April 15, 2013 2:35:10 PM UTC-6, Tobiah wrote:
> > tup = *func()
> What is the asterisk for? I assume it's a python 3
Not Python 3, pseudocode. I should have said as such, sorry. Supposed to
indicate an expanded tuple.
-- Gnarlie
--
http://mail.python.org/mailman/listinfo/python-li
I am trying to install mod_python on OSX 10.5, Intel version.
sudo apachectl configtest tells me this:
httpd: Syntax error on line 114 of /private/etc/apache2/httpd.conf:
Cannot load /usr/libexec/apache2/mod_python.so into server:
dlopen(/usr/libexec/apache2/mod_python.so, 10): no suitable imag
Hello.
The "upgrade to Python 3.1 has been disaster so far. I can't figure out how to
print Chinese to a browser. If my script is:
#!/usr/bin/python
print("Content-type:text/html\n\n")
print('晉')
the Chinese string simply does not print. It works in interactive Terminal no
problem, and also wo
Thanks for the help, but it doesn't work. All I get is an error like:
UnicodeEncodeError: 'ascii' codec can't encode character '\\u0107' in
position 0: ordinal not in range(128)
It does work in Terminal interactively, after I import the sys module.
But my script doesn't act the same. Here is my e
> you probably need to change the encoding of sys.stdout
>>> sys.stdout.encoding
'UTF-8'
>> #!/usr/bin/python
> do you know what python version, exactly, that gets called by this
hashbang?
Verified in HTTP:
>>> print(sys.version)
3.1.1
Is is possible modules are getting loaded from my old Python?
On Dec 1, 7:03 am, Mark Summerfield wrote:
> "Programming in Python 3 (Second Edition)" ISBN-10: 0321680561.
I ordered it...
-- Gnarlie
http://Gnarlodious.com
--
http://mail.python.org/mailman/listinfo/python-list
On Dec 1, 8:36 am, Lie Ryan wrote:
> #!/usr/bin/python
> import sys
> print = lambda s: sys.stdout.buffer.write(s.encode('utf-8'))
> print("Content-type:text/plain;charset=utf-8\n\n")
> print('晉\n')
HA! IT WORKS! Thank you thank you thank you. I don't understand the
lambda functionality but will
On Nov 30, 5:53 am, "Martin v. Löwis" wrote:
> #!/usr/bin/python
> print("Content-type:text/plain;charset=utf-8\n\n")
> sys.stdout.buffer.write('晉\n'.encode("utf-8"))
Does this work for anyone? Because all I get is a blank page. Nothing.
If I can establish what SHOULD work, maybe I can diagnose t
On Dec 2, 11:58 pm, Dennis Lee Bieber wrote:
> Have you tried
>
> sys.stdout.write("Content-type:text/plain;charset=utf-8\r\n\r\n")
Yes I tried that when it was suggested, to no avail. All I get is
"Internal server error". All I can imagine is that there is no
"sys.stdout.write" i
On Dec 1, 3:06 pm, Terry Reedy wrote:
> def print(s): return sys.stdout.buffer.write(s.encode('utf-8'))
Here is a better solution that lets me send any string to the
function:
def print(html): return sys.stdout.buffer.write(("Content-type:text/
plain;charset=utf-8\n\n"+html).encode('utf-8'))
Why
On Dec 5, 3:54 am, Lie Ryan wrote:
> Because of the switch to unicode str, a simple print('晉') should've
> worked flawlessly if your terminal can accept the character, but the
> problem is your terminal does not.
There is nothing wrong with Terminal, Mac OSX supports Unicode from
one end to the o
I am running a script in a browser that finds the file in subfolder
Data:
Content=Plist('Data/Content.plist')
However, running the same script in Terminal errors:
IOError: [Errno 2] No such file or directory: 'Data/Content.plist'
Is Py 3 unable to find relative paths? I tried all kinds of trick
On Jan 18, 4:21 pm, John Bokma wrote:
> Gnarlodious writes:
> > I am running a script in a browser that finds the file in subfolder
> > Data:
>
> > Content=Plist('Data/Content.plist')
>
> > However, running the same script in Terminal errors:
>
&g
I am using Python 3, getting an error from SQLite:
sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless
you use a text_factory that can interpret 8-bit bytestrings (like
text_factory = str). It is highly recommended that you instead just
switch your application to Unicode strings.
OK I guess that is normal, I fixed it with this:
path=os.path.dirname(__file__)+"/Data/"
-- Gnarlie
--
http://mail.python.org/mailman/listinfo/python-list
Well, Python 3 is supposed to be all Unicode by default. I shouldn't
even need to say
# coding:UTF-8
And, the file is saved as Unicode.
There are many mentions of this error found by Google, but none seen
to clearly say what the problem is or how to fix it.
FYI, the problem line says:
cursor.ex
Thanks for the help, but I am going to skip this problem because I
don't need Unicode characters in a script anyway.
-- Gnarlie
--
http://mail.python.org/mailman/listinfo/python-list
I want to declare several objects from names in a list:
objects=['object1', 'object2', 'object3', 'object4']
for objectName in objects:
objectName=classname()
That fails, and so do these:
exec(objectName)=classname()
eval(objectName)=classname()
So how to make an object whose name is th
On Jan 20, 8:31 pm, Ben Finney wrote:
> Since (I presume) you are a newcomer to Python, it's best to learn the
> common style http://www.python.org/dev/peps/pep-0008/>.
Thanks for that.
> This is almost certainly better done with a dictionary. Like so::
>
> object_names = ['object1', 'object2
1 - 100 of 149 matches
Mail list logo