Re: Printing UTF-8 mail to terminal

2024-11-05 Thread Cameron Simpson via Python-list
ponents can be identified mechanically. So it needs to be a syntacticly valid RFC5322 message. Thus the encoding. As an example (slightly contrived) of why this is important, multipart messages are delimited with distinct lines, and their content may not present such a line (even f it's in the "

Re: Printing UTF-8 mail to terminal

2024-11-05 Thread Peter J. Holzer via Python-list
On 2024-11-04 13:02:21 +0100, Loris Bennett via Python-list wrote: > "Loris Bennett" writes: > > "Loris Bennett" writes: > >> Cameron Simpson writes: > >>> On 01Nov2024 10:10, Loris Bennett wrote: > as expected. The non-UTF-8 text occurs when I do > > mail = EmailMessage() > >>>

Re: Printing UTF-8 mail to terminal

2024-11-04 Thread Loris Bennett via Python-list
"Loris Bennett" writes: > "Loris Bennett" writes: > >> Cameron Simpson writes: >> >>> On 01Nov2024 10:10, Loris Bennett wrote: as expected. The non-UTF-8 text occurs when I do mail = EmailMessage() mail.set_content(body, cte="quoted-printable") ... if arg

Re: Printing UTF-8 mail to terminal

2024-11-04 Thread Loris Bennett via Python-list
"Loris Bennett" writes: > Cameron Simpson writes: > >> On 01Nov2024 10:10, Loris Bennett wrote: >>>as expected. The non-UTF-8 text occurs when I do >>> >>> mail = EmailMessage() >>> mail.set_content(body, cte="quoted-printable") >>> ... >>> >>> if args.verbose: >>> print(mail) >>> >>>

Re: Printing UTF-8 mail to terminal

2024-11-04 Thread Loris Bennett via Python-list
Inada Naoki writes: > 2024年11月2日(土) 0:36 Loris Bennett via Python-list : > >> Left Right writes: >> >> > There's quite a lot of misuse of terminology around terminal / console >> > / shell. Please, correct me if I'm wrong, but it looks like you ar

Re: Printing UTF-8 mail to terminal

2024-11-04 Thread Loris Bennett via Python-list
Cameron Simpson writes: > On 01Nov2024 10:10, Loris Bennett wrote: >>as expected. The non-UTF-8 text occurs when I do >> >> mail = EmailMessage() >> mail.set_content(body, cte="quoted-printable") >> ... >> >> if args.verbose: >> print(mail) >> >>which is presumably also correct. >> >>T

Re: Printing UTF-8 mail to terminal

2024-11-02 Thread Inada Naoki via Python-list
Try PYTHONUTF8=1 envver. 2024年11月2日(土) 0:36 Loris Bennett via Python-list : > Left Right writes: > > > There's quite a lot of misuse of terminology around terminal / console > > / shell. Please, correct me if I'm wrong, but it looks like you are > > print

Re: Printing UTF-8 mail to terminal

2024-11-02 Thread Eli the Bearded via Python-list
In comp.lang.python, Gilmeh Serda wrote: > Python 3.12.6 (main, Sep 8 2024, 13:18:56) [GCC 14.2.1 20240805] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> help('modules') > > Please wait a moment while I gather a list of all available modules... > > Ass

Re: Printing UTF-8 mail to terminal

2024-11-02 Thread Jon Ribbens via Python-list
On 2024-11-01, Eli the Bearded <*@eli.users.panix.com> wrote: > In comp.lang.python, Gilmeh Serda wrote: >> Python 3.12.6 (main, Sep 8 2024, 13:18:56) [GCC 14.2.1 20240805] on linux >> Type "help", "copyright", "credits" or "license" for more information. >> >>> help('modules') >> >> Please wai

Re: Printing UTF-8 mail to terminal

2024-11-02 Thread Barry via Python-list
> On 1 Nov 2024, at 22:57, Left Right wrote: > > Does this Windows Terminal support the use > of programs like tmux? I have not tried, but should work. Best to install the terminal app from the MS app store. Most use I make is to ssh into linux systems and stuff like editors. Colour output a

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Left Right via Python-list
> Windows does now. They implemented this feature over the last few years. > Indeed they took inspiration from how linux does this. > > You might find https://devblogs.microsoft.com/commandline/ has interesting > articles about this. I don't have MS Windows. My wife does, but I don't want to both

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Barry via Python-list
> On 31 Oct 2024, at 16:42, Left Right via Python-list > wrote: > > MS Windows doesn't have or use > terminals (that's more of a Unix-related concept). Windows does now. They implemented this feature over the last few years. Indeed they took inspiration from how linux does this. You might f

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Cameron Simpson via Python-list
On 31Oct2024 21:53, alan.ga...@yahoo.co.uk wrote: On 31/10/2024 20:50, Cameron Simpson via Python-list wrote: If you're just dealing with this directly, use the `quopri` stdlib module: https://docs.python.org/3/library/quopri.html One of the things I love about this list are these little feat

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Cameron Simpson via Python-list
On 01Nov2024 10:10, Loris Bennett wrote: as expected. The non-UTF-8 text occurs when I do mail = EmailMessage() mail.set_content(body, cte="quoted-printable") ... if args.verbose: print(mail) which is presumably also correct. The question is: What conversion is necessary in order t

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Cameron Simpson via Python-list
On 01Nov2024 08:11, Loris Bennett wrote: Cameron Simpson writes: If you're using the Python email module to parse (or construct) the message as a `Message` object I'd expect that to happen automatically. I am using email.message.EmailMessage Noted. That seems like the correct approach to

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Dieter Maurer via Python-list
Loris Bennett wrote at 2024-11-1 10:10 +0100: > ... > mail.set_content(body, cte="quoted-printable") In the line above, you request the content to use the "cte" (= "Content-Transfer-Encoding") "quoted-printable" and consequently, the content is encoded with `quoted-printable`. Maybe, you do not n

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Loris Bennett via Python-list
Cameron Simpson writes: > On 31Oct2024 16:33, Loris Bennett wrote: >>I have a command-line program which creates an email containing German >>umlauts. On receiving the mail, my mail client displays the subject and >>body correctly: > [...] >>So far, so good. However, when I use the --verbose o

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Loris Bennett via Python-list
Left Right writes: > There's quite a lot of misuse of terminology around terminal / console > / shell. Please, correct me if I'm wrong, but it looks like you are > printing that on MS Windows, right? MS Windows doesn't have or use > terminals (that's more of

Re: Printing UTF-8 mail to terminal

2024-11-01 Thread Loris Bennett via Python-list
"Loris Bennett" writes: > Cameron Simpson writes: > >> On 31Oct2024 16:33, Loris Bennett wrote: >>>I have a command-line program which creates an email containing German >>>umlauts. On receiving the mail, my mail client displays the subject and >>>body correctly: >> [...] >>>So far, so good.

Re: Printing UTF-8 mail to terminal

2024-10-31 Thread Alan Gauld via Python-list
On 31/10/2024 20:50, Cameron Simpson via Python-list wrote: > That looks to me like quoted-printable. This is an encoding for binary > transport of text to make it robust against not 8-buit clean ... > If you're just dealing with this directly, use the `quopri` stdlib > module: https://docs.py

Re: Printing UTF-8 mail to terminal

2024-10-31 Thread Cameron Simpson via Python-list
On 31Oct2024 16:33, Loris Bennett wrote: I have a command-line program which creates an email containing German umlauts. On receiving the mail, my mail client displays the subject and body correctly: [...] So far, so good. However, when I use the --verbose option to print the mail to the ter

Re: Printing UTF-8 mail to terminal

2024-10-31 Thread Left Right via Python-list
There's quite a lot of misuse of terminology around terminal / console / shell. Please, correct me if I'm wrong, but it looks like you are printing that on MS Windows, right? MS Windows doesn't have or use terminals (that's more of a Unix-related concept). And, by "

Printing UTF-8 mail to terminal

2024-10-31 Thread Loris Bennett via Python-list
Hi, I have a command-line program which creates an email containing German umlauts. On receiving the mail, my mail client displays the subject and body correctly: Subject: Übung Sehr geehrter Herr Dr. Bennett, Dies ist eine Übung. So far, so good. However, when I use the --verbose opti

Re: Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )

2024-06-01 Thread Peter J. Holzer via Python-list
On 2024-05-30 21:47:14 -0700, HenHanna via Python-list wrote: > [('the', 36225), ('and', 17551), ('of', 16759), ('i', 16696), ('a', 15816), > ('to', 15722), ('that', 11252), ('in', 10743), ('it', 10687)] > > ((the 36225) (and 17551) (of 16759) (i 16696) (a 15816) (to 15722) (that > 11252) (in 1074

Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )

2024-05-31 Thread HenHanna via Python-list
;;; Pls tell me about little tricks you use in Python or Lisp. [('the', 36225), ('and', 17551), ('of', 16759), ('i', 16696), ('a', 15816), ('to', 15722), ('that', 11252), ('in', 10743), ('it', 10687)] ((the 36225) (and 17551) (of 16759) (i 16696) (a 15816) (to 15722) (that 11252)

Re: Printing dict value for possibly undefined key

2023-11-28 Thread Loris Bennett via Python-list
DL Neil writes: > On 11/25/2023 3:31 AM, Loris Bennett via Python-list wrote: >> Hi, >> I want to print some records from a database table where one of the >> fields contains a JSON string which is read into a dict. I am doing >> something like >>print(f"{id} {d['foo']} {d['bar']}") >> Howev

Re: Printing dict value for possibly undefined key

2023-11-28 Thread Loris Bennett via Python-list
duncan smith writes: > On 24/11/2023 16:35, duncan smith wrote: >> On 24/11/2023 14:31, Loris Bennett wrote: >>> Hi, >>> >>> I want to print some records from a database table where one of the >>> fields contains a JSON string which is read into a dict.  I am doing >>> something like >>> >>>    p

Re: Printing dict value for possibly undefined key

2023-11-25 Thread DL Neil via Python-list
On 11/25/2023 3:31 AM, Loris Bennett via Python-list wrote: Hi, I want to print some records from a database table where one of the fields contains a JSON string which is read into a dict. I am doing something like print(f"{id} {d['foo']} {d['bar']}") However, the dict does not always have

Re: Printing dict value for possibly undefined key

2023-11-25 Thread duncan smith via Python-list
On 24/11/2023 16:35, duncan smith wrote: On 24/11/2023 14:31, Loris Bennett wrote: Hi, I want to print some records from a database table where one of the fields contains a JSON string which is read into a dict.  I am doing something like    print(f"{id} {d['foo']} {d['bar']}") However, the d

Re: Printing dict value for possibly undefined key

2023-11-25 Thread duncan smith via Python-list
On 24/11/2023 14:31, Loris Bennett wrote: Hi, I want to print some records from a database table where one of the fields contains a JSON string which is read into a dict. I am doing something like print(f"{id} {d['foo']} {d['bar']}") However, the dict does not always have the same keys, so

Printing dict value for possibly undefined key

2023-11-25 Thread Loris Bennett via Python-list
Hi, I want to print some records from a database table where one of the fields contains a JSON string which is read into a dict. I am doing something like print(f"{id} {d['foo']} {d['bar']}") However, the dict does not always have the same keys, so d['foo'] or d['bar'] may be undefined. I ca

Re: PYLAUNCH_DEBUG not printing info

2022-06-09 Thread Eryk Sun
On 6/9/22, Peter Otten <__pete...@web.de> wrote: > > Looks like the variable is now called PYLAUNCHER_DEBUG: > > https://docs.python.org/3.11/using/windows.html#diagnostics I wonder why Steve changed the name of the environment variable without supporting the old "PYLAUNCH_DEBUG" name, at least fo

Re: PYLAUNCH_DEBUG not printing info

2022-06-09 Thread Peter Otten
On 09/06/2022 00:53, Richard David wrote: Why am I not getting debug output on my windows 10 machine: C:\temp>\Windows\py.exe -0 -V:3.11 *Python 3.11 (64-bit) -V:3.10 Python 3.10 (64-bit) C:\temp>set PYLAUNCH_DEBUG=1 C:\temp>\Windows\py.exe Python 3.11.0b3 (main, Jun 1 20

Re: PYLAUNCH_DEBUG not printing info

2022-06-09 Thread Peter Otten
On 09/06/2022 00:53, Richard David wrote: Why am I not getting debug output on my windows 10 machine: C:\temp>\Windows\py.exe -0 -V:3.11 *Python 3.11 (64-bit) -V:3.10 Python 3.10 (64-bit) C:\temp>set PYLAUNCH_DEBUG=1 C:\temp>\Windows\py.exe Python 3.11.0b3 (main, Jun 1 20

PYLAUNCH_DEBUG not printing info

2022-06-08 Thread Richard David
Why am I not getting debug output on my windows 10 machine: C:\temp>\Windows\py.exe -0 -V:3.11 *Python 3.11 (64-bit) -V:3.10 Python 3.10 (64-bit) C:\temp>set PYLAUNCH_DEBUG=1 C:\temp>\Windows\py.exe Python 3.11.0b3 (main, Jun 1 2022, 13:29:14) [MSC v.1932 64 bit (AMD64)] on

Re: Printing Unicode strings in a list

2022-04-30 Thread Chris Angelico
On Sun, 1 May 2022 at 00:03, Vlastimil Brom wrote: > (Even the redundant u prefix from your python2 sample is apparently > accepted, maybe for compatibility reasons.) Yes, for compatibility reasons. It wasn't accepted in Python 3.0, but 3.3 re-added it to make porting easier. It doesn't do anythi

Re: Printing Unicode strings in a list

2022-04-30 Thread Vlastimil Brom
"║"] ? > > 3. Given that I want to print a list of Unicode strings so that their > characters are displayed (instead of their Unicode codepoint definitions), > is there a more Pythonic way of doing it than concatenating them into a > single string and printing that? > &

Re: Printing Unicode strings in a list

2022-04-28 Thread Rob Cliffe via Python-list
On 28/04/2022 14:27, Stephen Tucker wrote: To Cameron Simpson, Thanks for your in-depth and helpful reply. I have noted it and will be giving it close attention when I can. The main reason why I am still using Python 2.x is that my colleagues are still using a GIS system that has a Python pro

Re: Printing Unicode strings in a list

2022-04-28 Thread Jon Ribbens via Python-list
o obvious reason why it *should*, and pretty decent reasons why it shouldn't (it would be a hybrid mess of Python-syntax repr output and raw string output). > 3. Given that I want to print a list of Unicode strings so that their > characters are displayed (instead of their Unicode codepoint

Re: Printing Unicode strings in a list

2022-04-28 Thread Stephen Tucker
> > >2. Should the second print statement produce [ ║] or ["║"] ? > > Well, to me its behaviour is correct. Do you _want_ to get your Unicode > glyph? in quotes? That is up to you. But consider: what would be sane > output if the list contained the string "], [3

Re: Printing Unicode strings in a list

2022-04-28 Thread Cameron Simpson
yph? in quotes? That is up to you. But consider: what would be sane output if the list contained the string "], [3," ? >3. Given that I want to print a list of Unicode strings so that their >characters are displayed (instead of their Unicode codepoint definitions), >is there a m

Printing Unicode strings in a list

2022-04-28 Thread Stephen Tucker
oes the second print statement not produce [ ║] or ["║"] ? 2. Should the second print statement produce [ ║] or ["║"] ? 3. Given that I want to print a list of Unicode strings so that their characters are displayed (instead of their Unicode codepoint definitions), is there a more P

Re: Problem with printing statement when condition is false

2021-03-05 Thread Terry Reedy
On 3/4/2021 4:28 PM, Terry Reedy wrote: Quentin privately sent me 12 lines (which should have been posted here instead), which can be reduced to the following 4 that exhibit his bug. if a == b:     print('correct')     if a != b:     print('incorrect') The bug is a != b will never be t

Re: Problem with printing statement when condition is false

2021-03-04 Thread Terry Reedy
On 3/4/2021 3:15 PM, Terry Reedy wrote: On 3/4/2021 12:10 PM, Quentin Bock wrote: I won't paste the code into this because it's 164 lines so I will attach a file copy, The alternative to posting too much is to reduce your code to the minimum needed to exhibit the behavior you want to change.

Re: Problem with printing statement when condition is false

2021-03-04 Thread Terry Reedy
On 3/4/2021 12:10 PM, Quentin Bock wrote: I won't paste the code into this because it's 164 lines so I will attach a file copy, The alternative to posting too much is to reduce your code to the minimum needed to exhibit the behavior you want to change. Doing so may reveal to you the solutio

Problem with printing statement when condition is false

2021-03-04 Thread Quentin Bock
Okay so, this is my biggest project, I'm not advanced in Python in any way so don't expect it to be perfect. I made a trivia game and for the most part, it works but I can't get it to print "Incorrect" and then what the answer was for all but one of my questions and I don't know why. I use PyCharm

chi square test in sklearn printing NAN values for most of the columns

2020-04-27 Thread Rahul Gupta
Hi i am trying to use chi-square Test to select most important columns among 5501 columns. But for most of the columns i am getting NAN value as a Chi test value import pandas as pd from sklearn.preprocessing import LabelEncoder from sklearn.feature_selection import chi2 cols =[] cols.append(int

Re: Why is the program not printing three lines?

2020-03-19 Thread Souvik Dutta
Ooo thanks I understood. On Thu, 19 Mar, 2020, 8:10 pm Pieter van Oostrum, wrote: > Souvik Dutta writes: > > > I should have been more clear > > class first(): > > print("from first") > > def second(): > > print("from second") > > first() > > > > When I run the above code the ou

Re: Why is the program not printing three lines?

2020-03-19 Thread Pieter van Oostrum
Souvik Dutta writes: > I should have been more clear > class first(): > print("from first") > def second(): > print("from second") > first() > > When I run the above code the output is > "from first" And where do you think this comes from? Are you thinking this comes from the cal

Re: Why is the program not printing three lines?

2020-03-19 Thread Rhodri James
On 19/03/2020 13:58, Souvik Dutta wrote: I should have been more clear class first(): print("from first") def second(): print("from second") first() When I run the above code the output is "from first" (2ND CODE) class first(): print("from first") def second():

Re: Why is the program not printing three lines?

2020-03-19 Thread Chris Angelico
On Fri, Mar 20, 2020 at 1:04 AM Souvik Dutta wrote: > > I should have been more clear > class first(): > print("from first") > def second(): > print("from second") > first() > > When I run the above code the output is > "from first" > (2ND CODE) > Try this *without* the call to fi

Re: Why is the program not printing three lines?

2020-03-19 Thread Souvik Dutta
I should have been more clear class first(): print("from first") def second(): print("from second") first() When I run the above code the output is "from first" (2ND CODE) class first(): print("from first") def second(): print("from second") first.second() When I

Re: Why is the program not printing three lines?

2020-03-19 Thread Pieter van Oostrum
Chris Angelico writes: > Creating the class runs all the code in the class block, including > function definitions, assignments, and in this case, a print call. > > Classes are not declarations. They are executable code. Demo: In [26]: class first(): ... print("From first") ...

Re: Why is the program not printing three lines?

2020-03-18 Thread Chris Angelico
On Thu, Mar 19, 2020 at 12:30 PM Souvik Dutta wrote: > > Hi, > I wrote a purposeless code today. > > class first(): > print("From first") > def second(): > print("From second") > first() > first.second() > > > Now the output I get is > From first > From second > > But when I comm

Why is the program not printing three lines?

2020-03-18 Thread Souvik Dutta
Hi, I wrote a purposeless code today. class first(): print("From first") def second(): print("From second") first() first.second() Now the output I get is >From first >From second But when I comment the call of first that is the comment the second last line of the code (#first()

Re: Pretty printing dicts with compact=True

2018-09-11 Thread Nicolas Hug
To me it also seems to be the most sensible behaviour, since dictionaries with their keys and values are different from most other sequences. You've got a point but 1. That goes against the compact=True expected behaviour 2. Small dicts (e.g. /{x: x for x in range(5)}/) are still printed on a

Re: Pretty printing dicts with compact=True

2018-09-11 Thread Max Zettlmeißl via Python-list
On Tue, Sep 11, 2018 at 1:58 PM, Nicolas Hug wrote: > pprint({x: x for x in range(15)}, compact=True) > > would be be printed in 15 lines while it could fit on 2. > > > Is this a bug or was this decided on purpose? It is on purpose as can be seen in the code for pprint [1], which calls _format [2

Pretty printing dicts with compact=True

2018-09-11 Thread Nicolas Hug
Is there a reason why the 'compact' parameter is ignored when pretty printing a dict? For example: pprint({x: x for x in range(15)}, compact=True) would be be printed in 15 lines while it could fit on 2. Is this a bug or was this decided on purpose? Thank you! -- https://mail.

Re: printing to stdout

2018-08-23 Thread richard lucassen
On Mon, 20 Aug 2018 08:19:12 +1000 Cameron Simpson wrote: [sorry for late reply] > Someone else has descibed zip tersely: it pairs it the elements of 2 > lists. In fact it joins up matching elements of an arbitrary number > of iterables. Here is a 3 iterable example: > > >>> zip( (1,2,3), (

Re: printing to stdout

2018-08-19 Thread Cameron Simpson
On 19Aug2018 15:09, richard lucassen wrote: On Sun, 19 Aug 2018 19:53:04 +1000 Cameron Simpson wrote: Although I do not understand what zip is doing exactly here (I presume I switch to use pointers instead of the values), Someone else has descibed zip tersely: it pairs it the elements of 2 li

Re: printing to stdout

2018-08-19 Thread Chris Angelico
On Mon, Aug 20, 2018 at 7:55 AM, Cameron Simpson wrote: > Draw little boxes with arrows. It helps. - Michael J. Eager Draw good boxes. - DeviCat ChrisA -- https://mail.python.org/mailman/listinfo/python-list

Re: printing to stdout

2018-08-19 Thread Cameron Simpson
On 19Aug2018 18:10, richard lucassen wrote: On Sun, 19 Aug 2018 10:11:08 -0400 Joel Goldstick wrote: Your allusion to pointers is misguided. Python is not like C or assembler. You don't, and don't need to know where objects are stored. Names are assigned to reference data objects I'll hav

Re: printing to stdout

2018-08-19 Thread Richard Lucassen
On Sun, 19 Aug 2018 12:37:18 -0400 Joel Goldstick wrote: > > I'll have another look at it, I was just searching for a clear > > explanation, but the page I found was not clear enough for me. I'll > > have to take some time for it... > > try python.org tutorial, and search for terms like names, o

Re: printing to stdout

2018-08-19 Thread Joel Goldstick
On Sun, Aug 19, 2018 at 12:16 PM Richard Lucassen wrote: > > On Sun, 19 Aug 2018 10:11:08 -0400 > Joel Goldstick wrote: > > > > Well, apparently there were quite a lot of things that makes the > > > code more readable I'd say. And even better. But it was indeed not > > > very unPythony. OTOH, I'm

Re: printing to stdout

2018-08-19 Thread Richard Lucassen
On Sun, 19 Aug 2018 10:11:08 -0400 Joel Goldstick wrote: > > Well, apparently there were quite a lot of things that makes the > > code more readable I'd say. And even better. But it was indeed not > > very unPythony. OTOH, I'm not a programmer, otherwise I would have > > written this in C ;-) >

Re: printing to stdout

2018-08-19 Thread richard lucassen
On Sun, 19 Aug 2018 19:53:04 +1000 Cameron Simpson wrote: > There are always unPythonic bits. Even after you've cleaned them all > up, since people will disagree about the finer points of Pythonicism > there will be bits both over and under cleaned. Although I do not understand what zip is doing

Re: printing to stdout

2018-08-19 Thread Joel Goldstick
On Sun, Aug 19, 2018 at 9:56 AM richard lucassen wrote: > > On Sun, 19 Aug 2018 12:02:51 +0300 > Marko Rauhamaa wrote: > > > richard lucassen : > > > As I'm new to Python, just this question: are there any unPythony > > > things in this code? > > > > Your code looks neat. > > Well, apparently the

Re: printing to stdout

2018-08-19 Thread richard lucassen
On Sun, 19 Aug 2018 12:02:51 +0300 Marko Rauhamaa wrote: > richard lucassen : > > As I'm new to Python, just this question: are there any unPythony > > things in this code? > > Your code looks neat. Well, apparently there were quite a lot of things that makes the code more readable I'd say. And

Re: printing to stdout

2018-08-19 Thread richard lucassen
On Sun, 19 Aug 2018 19:53:04 +1000 Cameron Simpson wrote: [Oops, apparently you set the Reply-To to python-list@python.org, normally that's no problem, but I did something wrong somewhere] > There are always unPythonic bits. Even after you've cleaned them all > up, since people will disagree abo

Re: printing to stdout

2018-08-19 Thread Cameron Simpson
On 19Aug2018 09:32, richard lucassen wrote: This is a working script I made. It initializes the I/O expanders, then it waits for an INT from these I/O expanders on GPIO23, reads the contents and sends which bit on which chip went up or down to a fifo (and stdout for logging) As I'm new to Pytho

Re: printing to stdout

2018-08-19 Thread Marko Rauhamaa
richard lucassen : > As I'm new to Python, just this question: are there any unPythony > things in this code? Your code looks neat. > except IOError: > print ("[ALERT] I/O problem device 0x%x" % list_pcf[i]) Just double check that simply printing the al

Re: printing to stdout

2018-08-19 Thread richard lucassen
On Fri, 17 Aug 2018 08:31:22 +1000 Cameron Simpson wrote: > Just looking at your loop I would be inclined to just call flush once > at the bottom, _before_ the sleep() call: > > sys.stdout.flush() > > Your call; the performance difference will be small, so it tends to > come down to keeping y

Re: printing to stdout

2018-08-17 Thread richard lucassen
On Fri, 17 Aug 2018 08:31:22 +1000 Cameron Simpson wrote: > This isn't specific to Python, you'll find it with most programmes. > (The shell's builtin "echo" command is an exception.) [buffer explanation] I already suspectec a buffered output and to check if it was the buffer, I created a lot o

Re: printing to stdout

2018-08-16 Thread Cameron Simpson
On 16Aug2018 22:37, richard lucassen wrote: I can run a shell script from the commandline as root in which I start a python script as user "ha". The output to stdout and stderr generated by the python script is visible in an xterm: #!/bin/dash exec 2>&1 chpst -u ha:ha:i2c -U ha /usr/local/ha/in

printing to stdout

2018-08-16 Thread richard lucassen
I can run a shell script from the commandline as root in which I start a python script as user "ha". The output to stdout and stderr generated by the python script is visible in an xterm: #!/bin/dash exec 2>&1 chpst -u ha:ha:i2c -U ha /usr/local/ha/init.sh exec chpst -u ha:ha:i2c:gpio /usr/local/h

Re: Finding a text in raw data(size nearly 10GB) and Printing its memory address using python

2018-04-23 Thread Hac4u
On Tuesday, April 24, 2018 at 4:13:17 AM UTC+5:30, MRAB wrote: > On 2018-04-23 22:11, Hac4u wrote: > > On Tuesday, April 24, 2018 at 12:54:43 AM UTC+5:30, MRAB wrote: > >> On 2018-04-23 18:24, Hac4u wrote: > >> > I have a raw data of size nearly 10GB. I would like to find a text > >> > string and

Re: Finding a text in raw data(size nearly 10GB) and Printing its memory address using python

2018-04-23 Thread MRAB
On 2018-04-23 22:11, Hac4u wrote: On Tuesday, April 24, 2018 at 12:54:43 AM UTC+5:30, MRAB wrote: On 2018-04-23 18:24, Hac4u wrote: > I have a raw data of size nearly 10GB. I would like to find a text string and print the memory address at which it is stored. > > This is my code > > import os

Re: Finding a text in raw data(size nearly 10GB) and Printing its memory address using python

2018-04-23 Thread Hac4u
On Tuesday, April 24, 2018 at 12:54:43 AM UTC+5:30, MRAB wrote: > On 2018-04-23 18:24, Hac4u wrote: > > I have a raw data of size nearly 10GB. I would like to find a text string > > and print the memory address at which it is stored. > > > > This is my code > > > > import os > > import re > > fi

Re: Finding a text in raw data(size nearly 10GB) and Printing its memory address using python

2018-04-23 Thread Hac4u
On Tuesday, April 24, 2018 at 1:28:07 AM UTC+5:30, Paul Rubin wrote: > Hac4u writes: > > I have a raw data of size nearly 10GB. I would like to find a text > > string and print the memory address at which it is stored. > > The simplest way is probably to mmap the file and use mmap.find: > > http

Re: Finding a text in raw data(size nearly 10GB) and Printing its memory address using python

2018-04-23 Thread bartc
On 23/04/2018 21:45, Stefan Ram wrote: MRAB writes: offset += search_length Or, offset += 1, to also find overlaps of that kind: file = "eee" word = "ee" . The above word "ee" occurs at position 0 and 1 in the file. My attempt: #include #include int main( void ) { FILE * const

Re: Finding a text in raw data(size nearly 10GB) and Printing its memory address using python

2018-04-23 Thread Grant Edwards
On 2018-04-23, Hac4u wrote: > I have a raw data of size nearly 10GB. I would like to find a text > string and print the memory address at which it is stored. The first thing I would try is to map the file into memory as a string (Pythonb 2) or bytearray (Python 3), and then search it using the f

Re: Finding a text in raw data(size nearly 10GB) and Printing its memory address using python

2018-04-23 Thread MRAB
On 2018-04-23 18:24, Hac4u wrote: I have a raw data of size nearly 10GB. I would like to find a text string and print the memory address at which it is stored. This is my code import os import re filename="filename.dmp" read_data=2**24 searchtext="bd:mongo:" he=searchtext.encode('hex') with op

Re: Finding a text in raw data(size nearly 10GB) and Printing its memory address using python

2018-04-23 Thread Hac4u
ndex(searchtext)) > > print offset > > except ValueError: > > print 'Not Found' > > else: > > continue > > You have a loop that reads a slab of data from a file, then searches > the curre

Re: Finding a text in raw data(size nearly 10GB) and Printing its memory address using python

2018-04-23 Thread Chris Angelico
a loop that reads a slab of data from a file, then searches the current data only. Then you search that again for the actual index, and print it - but you're printing the offset within the current chunk only. You'll need to maintain a chunk position in order to get the actual offset.

Finding a text in raw data(size nearly 10GB) and Printing its memory address using python

2018-04-23 Thread Hac4u
I have a raw data of size nearly 10GB. I would like to find a text string and print the memory address at which it is stored. This is my code import os import re filename="filename.dmp" read_data=2**24 searchtext="bd:mongo:" he=searchtext.encode('hex') with open(filename, 'rb') as f: while T

Re: Pandas printing in jupyter

2018-01-16 Thread Rustom Mody
On Tuesday, January 16, 2018 at 6:04:06 PM UTC+5:30, Rustom Mody wrote: Had missed the mtd element ie changing elemfmt = """%d """ to elemfmt = """%d """ -- https://mail.python.org/mailman/listinfo/python-list

Re: Pandas printing in jupyter

2018-01-16 Thread Rustom Mody
On Tuesday, January 16, 2018 at 5:10:14 PM UTC+5:30, Rustom Mody wrote: > On Sunday, January 14, 2018 at 3:28:02 AM UTC+5:30, bo...@questa.la.so wrote: > > Rustom Mody writes: > > > > > Specifically and for starters, I want a numpy array — lets say 2D to > > > start with — to be displayed(display

Re: Pandas printing in jupyter

2018-01-16 Thread Rustom Mody
On Sunday, January 14, 2018 at 3:28:02 AM UTC+5:30, bo...@questa.la.so wrote: > Rustom Mody writes: > > > Specifically and for starters, I want a numpy array — lets say 2D to > > start with — to be displayed(displayable) as elegantly as sympy does > > to (its) matrices > #

Re: Pandas printing in jupyter

2018-01-13 Thread boffi
bo...@questa.la.so writes: > def prmat(mat): > return (r'\begin{bmatrix}' + > r'\\'.join('&'.join('%f'%x for x in row) for row in mat) + > r'\end{bmatrix}' add a closing parenthesis here ^ -- https://mail.python.org/mailman/listinfo/python-list

Re: Pandas printing in jupyter

2018-01-13 Thread boffi
Rustom Mody writes: > Specifically and for starters, I want a numpy array — lets say 2D to > start with — to be displayed(displayable) as elegantly as sympy does > to (its) matrices import numpy as np from IPython.display im

Re: Pandas printing in jupyter

2018-01-11 Thread Rustom Mody
On Thursday, January 11, 2018 at 2:49:27 PM UTC+5:30, Thomas Jollans wrote: > On 2018-01-11 09:59, Rustom Mody wrote: > > On Thursday, January 11, 2018 at 2:13:46 PM UTC+5:30, Paul Moore wrote: > >> The HTML representation is supplied by the object's _repr_html_ > >> method. See https://ipython.or

Re: Pandas printing in jupyter

2018-01-11 Thread Thomas Jollans
On 2018-01-11 09:59, Rustom Mody wrote: > On Thursday, January 11, 2018 at 2:13:46 PM UTC+5:30, Paul Moore wrote: >> The HTML representation is supplied by the object's _repr_html_ >> method. See https://ipython.org/ipython-doc/3/config/integrating.html >> for some details. >> > import pandas

Re: Pandas printing in jupyter

2018-01-11 Thread Rustom Mody
On Thursday, January 11, 2018 at 2:13:46 PM UTC+5:30, Paul Moore wrote: > The HTML representation is supplied by the object's _repr_html_ > method. See https://ipython.org/ipython-doc/3/config/integrating.html > for some details. > > >>> import pandas as pd > >>> df = pd.DataFrame() > >>> df._rep

Re: Pandas printing in jupyter

2018-01-11 Thread Paul Moore
The HTML representation is supplied by the object's _repr_html_ method. See https://ipython.org/ipython-doc/3/config/integrating.html for some details. >>> import pandas as pd >>> df = pd.DataFrame() >>> df._repr_html_() '\n\n.dataframe tbody tr th:only-of-type {\n vertical-align: middle;\

Pandas printing in jupyter

2018-01-10 Thread Rustom Mody
If I make a data-frame in pandas in jupyter notebook it prints very nicely ie it looks quite like a spreadsheet How does it do it? Who does it? The data-frame does not seem to have str/repr methods… -- https://mail.python.org/mailman/listinfo/python-list

FW: Printing to a file and a terminal at the same time

2017-10-12 Thread Lie Ryan
It wouldn't be too difficult to write a file object wrapper that emulates tee, for instance (untested): class tee(object): def __init__(self, file_objs, autoflush=True): self._files = file_objs self._autoflush = autoflush def write(self, buf): for f in self._files

Re: FW: Printing to a file and a terminal at the same time

2017-10-10 Thread Michael Torrie
On 10/10/2017 10:09 AM, Vail, Rick wrote: > I have a script for Cisco devices that will do configuration or any CLI > command. What I would like to do is print the output to my terminal(windows) > and to a file. I can come up with stdout parameters > To print to a file but not to the screen and

Re: Printing to a file and a terminal at the same time

2017-10-10 Thread MRAB
On 2017-10-10 17:00, Vail, Rick wrote: I have a script for Cisco devices that will do configuration or any CLI command. What I would like to do is print the output to my terminal(windows) and to a file. I can come up with stdout parameters To print to a file but not to the screen and when I re

FW: Printing to a file and a terminal at the same time

2017-10-10 Thread Vail, Rick
Follow Presidio on Twitter]<http://www.twitter.com/presidio> From: Vail, Rick Sent: Tuesday, October 10, 2017 7:04 AM To: 'python-list@python.org' Subject: Printing to a file and a terminal at the same time I have a script for Cisco devices that will do configuration or any CLI

RE: Printing to a file and a terminal at the same time

2017-10-10 Thread Vail, Rick
I have a script for Cisco devices that will do configuration or any CLI command. What I would like to do is print the output to my terminal(windows) and to a file. I can come up with stdout parameters To print to a file but not to the screen and when I remove the stdout part it prints to the sc

  1   2   3   4   5   6   7   8   9   10   >