Okay, it appears the method in a class has its own ID, but all
instantiations of that method have identical IDs. But what happens if we
have a huge number of instantiations trying to access the identical method
at the same time?
class MyClass:
def setdata(self, data):
self.data = data
When an instance uses a class method, does it actually use the method that
is in the class object's memory space, or is the method copied to the
instance?
--
Jim
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http
'''I was using with open...:, but I'm printing a header in one function,
calling a looping
function to print detail lines, then returning to the calling function to
print
the footer. But that didn't work since the with statement only seems to work
with the lexical suite and the file wasn't open in
On 20 May 2015 at 01:02, Peter Otten <__pete...@web.de> wrote:
> If you start with an object dir() gives you a list of attribute names. To
> get the actual attributes use
>
> attribute = getattr(object, attribute_name)
>
> Then print the attributes' docstring with
>
> print(attribute_name, attribu
On 19 May 2015 at 17:25, Jim Mooney Py3.4.3winXP
wrote:
>
> If I can get dir to accept x I can parse the output to get rid of the
> __xxx stuff and print it out.
>
By that I mean dir will give me a list of strings I can then use __doc__ on
to get all useful help items.
--
Ji
On 19 May 2015 at 17:18, Ben Finney wrote:
> You will be pleased to know of the standard library ‘importlib’
> library::
>
> >>> import importlib
>
Yes, I already got importlib to accept a string. But I can't figure how to
get dir to accept it:
>>> x = 'shutil'
>>> import importlib
>>> impo
I use python help() a good deal but get tired of paging through the
__object__ stuff to get to what I use at my level, so I wrote the following
to omit it. The problem is, I want to import it then use it as shorthelp.py
for different modules so I could just type shorthelp(modulename). Only the
impo
On 15 May 2015 at 22:45, Steven D'Aprano wrote:
>
> What does "didn't work" mean? Did your computer crash? Catch fire? A
> completely different error got printed? Something else?
I can see I was marvelously unclear ;') Here is what I meant.
def make_error():
raise ZeroDivisionError('Here I
On 14 May 2015 at 16:47, Alan Gauld wrote:
> Rather than printing the messages you could re-raise
> the error but with the error message attached as a string.
>
I'm a little unclear how you catch the string you create in a raise, in the
caller. I tried an example from the docs but it didn't work
I noticed that if I call a function that throws an error, I can catch it
from the caller, instead of catching it in the function. Is this is what is
known as "errors bubbling up?" Also, is this how you're supposed to do it?
*** Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600
On 7 May 2015 at 18:42, Dave Angel wrote:
> Python doesn't have pointers
So what is the difference between a python name and a pointer? I'm a bit
fuzzy on that.
--
Jim
"What a rotten, failed experiment. I'll start over. Maybe dogs instead of
monkeys this time." --God
___
On 7 May 2015 at 13:03, Emile van Sebille wrote:
> Compare to:
>
> def testid(K=100):
> K += 10
> return 'the ID is', id(K), K
>
Ah, thanks. I forgot small integers are saved in a table. I was looking at
a demo that pointers to defaults in function parameters are persistent. It
use
I find this a bit confusing. Since the ID of K remains the same, so it's
the same object, why isn't it increasing each time. i.e, 20, 30, 40,. I
understand that it's immutable but doesn't that mean K is created each time
in local scope so it should have a different ID each time?
def testid(K=10):
On 6 May 2015 at 14:08, Dave Angel wrote:
> I don't know why you would be expecting to get a utf-8 character for the
> second byte of a function key code. It's an entirely arbitrary byte
> sequence, and not equivalent to anything in Unicode, encoded or not
I just didn't think of accounting for
On 6 May 2015 at 10:41, Jim Mooney Py3.4.3winXP
wrote:
> I went a further step from the recipes linked to above and got here
>> https://pypi.python.org/pypi/readchar
>
>
> I think that's the one that failed for me
>
Addendum. That only failed in python 3.4. It worked
On 5 May 2015 at 21:51, Mark Lawrence wrote:
> On 06/05/2015 05:30, Jim Mooney Py3.4.3winXP wrote:
>
>> On 5 May 2015 at 18:32, Steven D'Aprano wrote:
>>
>> https://code.activestate.com/recipes/577977-get-single-keypress/
>>>
>>
>>
>> Th
On 5 May 2015 at 18:32, Steven D'Aprano wrote:
> https://code.activestate.com/recipes/577977-get-single-keypress/
That only has a stub for Linux, but I found one that does both. Although,
alas, no IOS version:
http://code.activestate.com/recipes/134892-getch-like-unbuffered-character-reading-
On 5 May 2015 at 18:35, Steven D'Aprano wrote:
> Is this under Linux or another Unix? If so, > only redirects stdout, not
> stderr, so you need:
>
> python3 setup.py 2> errors.txt
>
> to capture the errors.
>
> I have no idea if Windows works the same way.
>
Damn, that actually worked in windows
On 5 May 2015 at 16:47, Jim Mooney Py3.4.3winXP
wrote:
> But that didn't work. How can I get a printout of setup errors so I can
> post them?
I remembered how to copy the DOS console. Here is the error. Error wasn't
in setup.py so that wouldn't have worked anyway.
On 5 May 2015 at 15:36, Alan Gauld wrote:
> Can python detect a keypress?
>>
>
> That sounds simple but is actually quite tricky
> since it's terminal dependent.
An ancillary question. I found a readchar that purports to install in py2
and 3 but fails in 3. The errors (something from the encodi
Can python detect a keypress? I've looked all over and can't find it. I
don't mean input('blah') and have to press Enter - just detect it directly
like Javascript does. All I find are references using msvcrt, which is
Msoft specific, or using tkinter - but I don't want a whacking big GUI,
just keyp
Oops, my mistake. Ignore dumb remark below. I was thinking of the try -
except in the main loop, but since I only tested the parse function, I
never used that. I need to look a bit harder and find this stuff Before I
post ;')
Jim
On 29 April 2015 at 23:04, Jim Mooney Py3.4.3winXP wrote:
Sure, but let me include the full working program after fixup
On 29 April 2015 at 19:09, Cameron Simpson wrote:
>
> These could all do with docstrings. add() is pretty obvious, but the
> distinction between minus() and subtract() could do with elaboration.
etc, etc.
Thanks. Very comprehens
On 29 April 2015 at 21:14, Dave Angel wrote:
> But why are you surprised? There's no try/except protecting the latter
> line, so the exception will be uncaught, and you'll see it reported in
> parse_string().
>
I think I meant something like this. An exception in a function is caught
by the cal
I raised an exception in the parse_string function in my math parser
program, function_tosser.py, and caught it in the calling routine, and that
worked fine. But when I imported function_tosser.py into a test program,
tester.py, it threw the exception in the parse_string function instead of
handlin
On 28 April 2015 at 22:40, Cameron Simpson wrote:
>
> As with all things, sometimes that cannot be reasonably achieved, but it
> is usually so.
>
> We can pick over your code as well if you like. Should we?
>
> Cheers,
> Cameron Simpson
Sure, but let me include the full working program after f
On 28 April 2015 at 21:27, Cameron Simpson wrote:
> At a first glance numbers is a global. It is reset to [] at program start,
> but never again. So you're appending to it forever. I have not investigated
> further as to how that affects your program's flow.
>
> Cheers,
> Cameron Simpson
>
Took
This is really puzzling me. I'm parsing a string to do some simple math
operations and practice tossing functions around. My parser works on the
first run, then it continually fails on the same input.
"""
Takes the name of a binary math operation and two numbers from input,
repeatedly, and display
On 26 April 2015 at 04:02, Steven D'Aprano wrote:
> for kind in (int, float):
> try:
> return kind(astring)
>
That puzzled me for a moment until I remembered you can toss functions
around in Python. Something to play with on a Sunday afternoon ;')
But aren't most langua
On 25 April 2015 at 21:28, Steven D'Aprano wrote:
> What REPL are you using? I can't reproduce what you are
> reporting in the standard Python 3.3 interactive interpreter. When I
> print the transit_info I get a single block of text:
>
Ah, found the problem. I was looking at PyScripter output. W
It seems odd to me that there are three tests to see if user input is
digits - isdecimal, isdigit, isnumeric, but nothing to test for a float
unless you use a try - except. Or did I miss something? Anyway, I tried a
try - except, but I don't see why my output is all integer when I only
convert to i
On 25 April 2015 at 17:43, Alan Gauld wrote:
> know what's going on. I seem to recall you are using Python 3,
> is that correct?
>
>
I guess I should specify from now on py3 on win xp
Another question - why does the first assignment work but not the second. I
can see it's a syntax error but if
On 25 April 2015 at 18:03, Ben Finney wrote:
> Digest mode should only ever be used if you know for certain you will
> never be responding to any message.
>
That brings up a great shortcut if you use gmail. If you select some text
before reply that's All that is sent. Cuts way down on huge reply
I'm curious why, when I read and decode a binary file from the net in one
fell swoop, the REPL prints it between parentheses, line by line but with
no commas, like a defective tuple. I can see breaking lines visually, at
\n, but if the parentheses don't mean anything I can't see including them.
Or
>
> Hm, who the heck uses "u8"? I'd rather go with
>
> >>> encodings.aliases.aliases["steven_s_preferred_encoding"] = "utf_8"
> >>> "Hello".encode("--- Steven's preferred encoding ---")
> b'Hello'
>
> ;)
>
Peter Otten
> __
>
Or normalize almost any mistyping ;'):
>>> encodings.normalize_encodin
> See 7.2.3 (aliases) and 7.2.7 (utf_8_sig) in the codecs documentation.
>
> https://docs.python.org/3/library/codecs.html
>
The docs don't mention that case is immaterial for aliases, when it usually
matters in Python. The actual dictionary entries in aliases.py often differ
in case from the docs
>
>
> I wouldn't use utf-8-sig for output, however, as it puts the BOM in the
> file for others to trip over.
>
> --
> DaveA
Yeah, I found that out when I altered the aliases.py dictionary and added
'ubom' : 'utf_8_sig' as an item. Encoding didn't work out so good, but
decoding was fine ;')
_
Unicode for Idiots indeed, a Python list can always find something better
than that :)
>
> http://www.joelonsoftware.com/articles/Unicode.html
> http://nedbatchelder.com/text/unipain.html
>
>
> Mark Lawrence
>
>
Batcheder's looks good. I'm going through it. I tried the Unicode
Consortium website a
Actually,. I found the aliases in Lib/encodings/aliases.py and added an
alias:
>>> deco = bytes("I sure hate apples.", encoding='ubom')
>>> deco
b'\xef\xbb\xbfI sure hate apples.'
>>>
Tricky, though - if you don't put a comma at the end of your alias, it
breaks Python (or my Pyscripter editor, an
It looks like sig works for any dash, underline combination, and is ignored
if there is no BOM:
>>> farf = bytes('many moons ago I sat on a rock', encoding='utf8')
>>> farf
b'many moons ago I sat on a rock'
>>> str(farf, encoding="utf_8_sig")
'many moons ago I sat on a rock'
>>> str(farf, encoding
>
> Apparently so. It looks like utf_8-sig just ignores the sig if it is
> present, and uses UTF-8 whether the signature is present or not.
>
> That surprises me.
>
> --
> Steve
>
>
I was looking things up and although there are aliases for utf_8 (utf8 and
utf-8) I see no aliases for
You can save yourself some time and use a raw string:
> print(r""" """)
>
> Timo
>
> Good point. I'll go to site-packages and change that. I import Bob to
cheer myself up as I look at Unicode, which is like forcing a kid to go to
Sunday school on a bright Summer day, instead of playing with P
I was depressed at the thought of learning unicode, then discovered Python
was fun again since I can easily print any ascii art from
http://www.chris.com/ascii/ with a multiline print, so long as I replace
any backslash with two of them. Spongebob Squarepants was, of course, the
obvious first choi
So is there any way to sniff the encoding, including the BOM (which appears
to be used or not used randomly for utf-8), so you can then use the proper
encoding, or do you wander in the wilderness?
Pretty much guesswork.
>
Alan Gauld
--
This all sounds suspiciously like the old browser wars I suf
>
> By relying on the default when you read it, you're making an unspoken
> assumption about the encoding of the file.
>
> --
> DaveA
So is there any way to sniff the encoding, including the BOM (which appears
to be used or not used randomly for utf-8), so you can then use the proper
encoding, or
..
> Ï»¿
>
> is the UTF-8 BOM (byte order mark) interpreted as Latin 1.
>
> If the input is UTF-8 you can get rid of the BOM with
>
> with open("data.txt", encoding="utf-8-sig") as csvfile:
>
Peter Otten
I caught the bad arithmetic on name length, but where is the byte order
mark coming from? My
I'm trying the csv module. It all went well until I tried shortening a long
first name I put in just to exercise things. It didn't shorten. And I also
got weird first characters on the header line. What went wrong?
import csv
allcsv = []
with open('data.txt') as csvfile:
readCSV = csv.reader(c
Is there any difference between these two since they give the same result,
and when is the second preferred?
>>> x = 'ABE'
>>> x.lower()
'abe'
>>> str.lower(x)
'abe'
--
Jim
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription o
Why does the compiler choke on this? It seems to me that the enhanced
subtraction resolves to a legitimate integer in the exponent, but I get a
syntax error:
B = '11011101'
sum = 0
start = len(B)
for char in B:
sum += int(char) * 2**(start -= 1) ## syntax error
print(sum)
--
Jim
___
The key is that the result gets multiplied by 2 each time
> so for an N bit number the leftmost digit winds up being
> effectively 2**N, which is what you want.
>
> Alan G
Ah, the light dawns once it was restated. It would be even simpler if you
could multiply each element of the binary numbe
> Which is why you should use the csv module to work with csv files,
> it knows how to deal with these various exceptional cases.
> --
> Alan G
>
I should have known to simply try importing csv.
Must-remember-batteries-included ;')
--
Jim
___
Tutor mai
I can't seem to get my head around this 'simple' book example of
binary-to-decimal conversion, which goes from left to right:
B = '11011101'
I = 0
while B:
I = I * 2 + int(B[0])
B = B[1:]
print(I)
>>> 221
My thought was to go from right to left, multiplying digits by successive
powers of
For randomly generating data which look like addresses, I use:
> http://www.generatedata.com/
>
> While it has 'export to programming language' as a feature, Python isn't
> one of the supported languages. Which is fine. It can export into comma
> separated values, and writing a Python program to
Where could I download Python sample dictionaries on different subjects.
They're hard to type and I can only do small, limited ones to practice with.
--
Jim
The probability of a piano falling on my head is 50%. After it falls on my
head the probability is 100%. My confidence in the piano hitting
The whole point of the discussion is that this is *not* a presentation
issue. Fraction(1.64) and Fraction("1.64") *are* two different numbers
because one gets constructed from a value that is not quite 1.64.
Wolfgang Maier
--
So the longer numerator and denominator would, indeed, be more accurate
>
> Is this "inaccurate"? Well, in the sense that it is not the exact true
> mathematical result, yes it is, but that term can be misleading if you
> think of it as "a mistake". In another sense, it's not inaccurate, it is
> as accurate as possible (given the limitation of only having a certain
> f
Why does Fraction interpret a number and string so differently? They come
out the same, but it seems rather odd
>>> from fractions import Fraction
>>> Fraction(1.64)
Fraction(738590337613, 4503599627370496)
>>> Fraction("1.64")
Fraction(41, 25)
>>> 41/25
1.64
>>> 738590337613 / 45035996273
I'm guessing; but I'd expect it to be the current directory
> when you started the server. try adding a
>
> print( os,getcwd() )
>
> And see if the result is your root.
> Or you could try reading the documents...they might tell you!
>
> --
> Alan G
Read the docs? Where's the fun in that ;')
Act
I set up a simple python wsgi server on port 8000, which works, but where
the heck is the server root? Is there a physical server root I can simply
put a python program in, as I put a html program into the wampserver root,
and see it in a browser on localhost:port 8000, or do I need to do a bit
mo
> Chaining long strings of operations together in a single statement goes
> directly against that principle, and hence is to be avoided.
>
> Ben Finney
>
>
A hard habit to break after using jQuery as a webmaster ;')
--
Jim
"Stop, Harold! That bagel has radishes!"
"Thank God, Mary - you've saved m
> That's an interesting feature. It's not sufficient though: the resulting
> messages lack the full header of each message, so any reply will not be
> properly marked as a response to the original.
>
> The only way to participate properly in a discussion on a mailing list
> is to respond to the act
On Apr 12, 2015 4:00 PM, "Jim Mooney" wrote:
> >
> > If join returns a string, why am I getting a syntax error when I try to
> > slice it?
> >
> > >>> 'alfabeta'[2:5]
> > 'fab'
> > >>> ''.join(
If join returns a string, why am I getting a syntax error when I try to
slice it?
>>> 'alfabeta'[2:5]
'fab'
>>> ''.join(['a', 'l', 'f', 'a', 'b', 'e', 't', 'a')[2:5]
SyntaxError: invalid syntax
--
Jim
___
Tutor maillist - Tutor@python.org
To unsubsc
> Range objects are special: not only do they produce values lazily as
> needed, but they also support len(), indexing, slicing, and membership
> testing, none of which generators are capable of doing:
>
> Steve
-
That's really cool. Worth making a dumb mistake to find it out ;')
Jim
Today is
I thought I'd get [2,3,4,5] from this but instead I get nothing. Why isn't
it chaining?
>>> q = list(set([1,2,3,1,4,1,5,1,5])).remove(1)
>>> q
>>>
--
Jim
Today is the day that would have been yesterday if tomorrow was today
___
Tutor maillist - Tuto
Why does the first range convert to a list, but not the second?
>>> p = list(range(1,20)), (range(40,59))
>>> p
([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
range(40, 59))
--
Jim
"Stop, Harold! That bagel has radishes!"
"Thank God, Mary - you've saved me again!"
__
"The safest method would probably be to do `pip freeze > requirements.txt`,
copy the requirements.txt file to the new machine, and run `pip install -r
requirements.txt" --Zach
I looked at pip3 help (windows) and don't see a -r command. However, it
does work. How do I get the "invisible" commands
Lxml 2.3
PySerial 2.5
PyODBC 3.0.2
PyQt 4.9.6-1
IPython 0.13.1
Pandas 0.11.0
On 8 April 2015 at 04:44, Zachary Ware wrote:
> On Apr 8, 2015 3:39 AM, "Jim Mooney" wrote:
> >
> > General question. I'm thinking of moving to a new machine although
General question. I'm thinking of moving to a new machine although I hate
to abandon trusty XP. Will I have to reinstall all my pip installed modules
or can I just copy the site-packages directory? And if so, is anything else
needed, such as where pip keeps its uninstall info?
Finally, is there su
Why did this fail where it did? It failed at listing the result of the
filter of a word list, but I figured if it failed, it would have done so at
the filter.
>>> words = open('5desk.txt').readlines()
>>> k = [word.rstrip for word in words]
>>> len(k)
61406
>>> p = filter(lambda word: len(word) >
I'm looking at this and can't see how it works, although I understand
zipping and unpacking. The docs say it's a Python idiom. Does "idiom" mean
it works in a special way so I can't figure it out from basic principles?
It looks to me like the iterator in the list gets doubled, so the zip
should mak
Shouldn't this give me a list of squares?
[lambda x: x**2 for x in range(10)]
Instead I'm getting ten of these (with different addresses)
. at 0x01262A50>]
--
Jim
I can't think of a clever tagline today, so just imagine I said something
clever.
___
Tu
> From: Kimberly Mansfield
> This is the first homework assignment. Driving me crazy - struggling
> with it for two entire days. I want to drop this class now.
Does the Python interpreter run with even a simple program such as
print('hello') ?
If it doesn't run that, it may be a windows or inst
r, if you could even find them, and then they'd say they had no
authority to make a change until it was reviewed by the Committee of 400, a
year from now ;')
Jim
On 23 August 2013 01:18, Francesco Loffredo wrote:
> Omar Abou Mrad wrote:
>
>>
>>
>>
>> O
nt doesn't
always work for a number of things.
Jim
On 21 August 2013 03:20, Chris Down wrote:
> On 2013-08-20 21:52, Jim Mooney wrote:
> > This is rather like W3 Schools
>
> That doesn't exactly fill me with confidence about the quality of it
> considering W3Schools i
http://interactivepython.org
Since there has been some mention of courses lately, I think this has
become the best online Python course: "How to Think Like a Computer
Scientist." It has an interactive Online Interpreter, where you can
run the examples, or change things and experiment with new code
On 12 August 2013 02:14, Karim Liateni wrote:
> 5ÿt5ÿ6hhhyyyfrrtr
>
> eschneide...@comcast.net a écrit :
>
> >I've been learning python from the website 'inventwithpython.com', and
> I'm on a chapter that covers the following code:
>
Just a quick note - not on the algorithm itself. If you run th
On 23 July 2013 07:28, Steven D'Aprano wrote:
>
> (I trust that everyone remembers enough high school chemistry to
> understand why Mercurial is called hg? Hg is the chemical symbol for
> Mercury.)
>
And I recall my high school chemistry teacher claiming the noble gases
could never combine, unti
On 23 July 2013 07:19, Steven D'Aprano wrote:
> Some day, I'll invent my own version of Python, and make object IDs be
> consecutive prime numbers. That'll teach people to rely on them.
>
---
Why "consecutive?" That's still way too predictable (Yes, the obvious flaw
already occurred to me ;')
On 23 July 2013 07:46, Steven D'Aprano wrote:People
who talk about
"extended ASCII" are confused, and all you need to do to show up their
confusion is to ask "which extended ASCII do you mean?" There are dozens.
I think I was too impressed by all those wonderful old ASCII-art pics on
bulletin
On 23 July 2013 07:21, Oscar Benjamin wrote:
>
>
> You can check the size in bytes of an object with sys.getsizeof e.g.:
>
> >>> import sys
> >>> sys.getsizeof(lardKronk)
> 36
>
And yet I still get 36 with this:
bigKronk = Kronk('supercalifracilisticexpalidocious, even though the sound
of it is
On 23 July 2013 01:13, Marc Tompkins wrote:
When I saved your code as a file on my machine (Python 2.7 on Win8 64-bit)
> and ran it from the command line, I got the same result as you - three IDs,
> 40 apart every time. However, I initially pasted your code into
> PyScripter, and when I ran it i
On 23 July 2013 00:42, Steven D'Aprano wrote:
My, that is simple. The Python docs should start with simple explanations
like that so people would keep on reading instead of throwing up their
hands in despair ;')
>
> - use the encode method to go from text to bytes, and decode to go the
> other w
On 23 July 2013 00:40, Steven D'Aprano wrote:
>
> No no no, a thousand times no!!! IDs are just numeric IDs, that is all,
> like your social security number or driver's licence number. Don't think of
> them as having any meaning at all, except that they are unique during the
> lifetime of the obj
I've noticed that when I create a number of objects from a class, one after
another, they're at different IDs, but the IDs all appear to be
equidistant, so that they all appear to have the same size. But what does
that size represent? is it bytes? ie - if I run this over and over I get
different id
On 22 July 2013 21:00, Steven D'Aprano wrote:
>
> (By the way, you're very naughty. The code you show *cannot possibly
> generate the error you claim it generates*. Bad Jim, no biscuit!)
>
I know. I need a personal github. When I get frustrated I try so many
things in quick succession I lose tra
Steven D'Aprano
When Python starts up, it needs to set the encoding used, but you *cannot*
> set it to arbitrary encodings. Setting it to arbitrary encodings can cause
> all sorts of weird, hard to diagnose bugs, so to prevent that, Python
> deletes the setdefaultencoding function after using it.
On 22 July 2013 15:12, Alan Gauld wrote:
When I used an old VT220 on a VAX I always used to reverse the display to
> show black characters on a light (green or amber) screen. It used to freak
> out my colleagues who were traditionalist green on black men...
>
I think a lot of old sonar guys went
On 22 July 2013 14:11, Marc Tompkins wrote:
>
> One way to deal with this is to specify an encoding:
> newchar = char.decode('cp437').encode('utf-8')
>
Works fine, but I decided to add a dos graphics dash to the existing dash
to expand the tree
visually. Except I got a complaint from IDLE th
> Just to clarify, tree isn't completely Unicode naive. It writes
> Unicode to the console, presuming you're using a font that supports
> it, such as Consolas.
>
I'm sticking to 20 pt Lucida Console on a big, full screen DOS box with
navy letters and cyan background. If you have a big screen migh
On 22 July 2013 14:15, Marc Tompkins wrote:
>
>
> You could do worse... Again, my issue with TREE is that it willfully
> throws away information (non-ASCII characters in filenames) before passing
> it on to you. As a result, the tree you print out may not correspond to
> the actual filesystem s
On 22 July 2013 14:11, Marc Tompkins wrote:
The error's in your error message: Python has decoded the string properly,
> but (since you haven't specified an encoding) is trying to encode to the
> default, which in Python < 3 is 'ascii'... which has a great big blank
> space where all characters
On 22 July 2013 12:48, Marc Tompkins wrote:
>
>
> You'd be better off skipping TREE entirely and going pure-Python. TREE -
> being Unicode-naive - can't deal with any foreign-alphabet characters
> beyond the few baked in alongside the box-drawing characters; they all get
> turned into question m
On 22 July 2013 13:45, Marc Tompkins wrote:
>
> inFileName = "/Users/Marc/Desktop/rsp/tree.txt"
> with open(inFileName, 'r') as inFile:
> inString = inFile.read().decode('cp437')
> print inString
>
> I already tried something similar and got an error:
with open('../pytree
On 22 July 2013 11:52, Alan Gauld wrote:
> On 22/07/13 19:14, Jim Mooney wrote:
>
> zark += unichr(ord(x)-45)
>>
>>
>> unichr() arg not in range(0x1) (narrow Python build)
>>
>
>
> What if ord() is returning a value less than 45?
&
Okay, I'm getting there, but this should be translating A umlaut to an old
DOS box character, according to my ASCII table, but instead it's print
small 'u':
def main():
zark = ''
for x in "ÀÄÄÄ":
print(unichr(ord(u'x')-3), end=' ')
result: u u u u
--
Jim
What the Nations of the
I had a bad feeling I'd end up learning Unicode ;')
>
>
> It's not as painful as you might think! Try it - you'll like it!
> Actually, once you start getting used to working in Unicode by default,
> having to deal with programs that are non-Unicode-aware feels extremely
> irritating.
>
I'll have
On 22 July 2013 11:26, Marc Tompkins wrote:
>
>
>
> If you haven't already read it, may I suggest Joel's intro to Unicode?
> http://www.joelonsoftware.com/articles/Unicode.html
>
I had a bad feeling I'd end up learning Unicode ;')
--
Jim
___
Tutor ma
I tried translating the odd chars I found in my dos tree /f listing to
symbols, but I'm getting this error. The chars certainly aren't over
1, The ord is only 13 - so what's wrong here?
def main():
zark = ''
for x in "ÀÄÄÄ":
zark += unichr(ord(x)-45)
print(zark)
unichr(
On 22 July 2013 03:51, eryksun wrote:
> On Sun, Jul 21, 2013 at 9:18 PM, Marc Tompkins
> wrote:
>
> CP/M itself didn't use '/' switches in its internal CCP commands, even
> if some 3rd party programs did. Neither did COMMAND.COM in Tim
> Paterson's 86-DOS. Microsoft added the switches (but Pater
1 - 100 of 284 matches
Mail list logo