ion like the other solutions but is truly changing
> the defaults for the existing function print?
No. You are absolutely not changing the defaults for the actual built-in print
function. There is no support for that in Python.
What is happening is a bit more complex, but simplified:
- func
In article ,
eryk...@gmail.com says...
>
> On Mon, Oct 9, 2017 at 10:04 PM, John Black wrote:
> > In article , python@example.invalid says...
> >>
> >> Le 09/10/2017 à 18:22, John Black a écrit :
> >> > I want sep="" to be the default without having to specify it every time I
> >> > call print.
On Mon, Oct 9, 2017 at 10:04 PM, John Black wrote:
> In article , python@example.invalid says...
>>
>> Le 09/10/2017 à 18:22, John Black a écrit :
>> > I want sep="" to be the default without having to specify it every time I
>> > call print. Is that possible?
>>
>> >>> oldprint = print
>> >>>
On 2017-10-09, John Black wrote:
> I want to make sure I understand what this line is doing:
>
>> oldprint = print
>
> Experimenting, I find this is not a rename because I can use both
> function names.
Right it's not _changing_ a name. It's _adding_ a name.
> It looks it literally copies th
In article , python@example.invalid says...
>
> Le 09/10/2017 à 18:22, John Black a écrit :
> > I want sep="" to be the default without having to specify it every time I
> > call print. Is that possible?
>
> >>> oldprint = print
> >>> def print(*args,**kwargs):
> ... oldprint(*args,**kwargs,
On Tue, Oct 10, 2017 at 7:40 AM, John Black wrote:
> In article ,
> __pete...@web.de says...
>>
>> John Black wrote:
>>
>> > I want sep="" to be the default without having to specify it every time I
>> > call print. Is that possible?
>>
&
In article ,
__pete...@web.de says...
>
> John Black wrote:
>
> > I want sep="" to be the default without having to specify it every time I
> > call print. Is that possible?
>
> No, but you can replace the print function with your own:
>
&g
On 10/9/2017 12:22 PM, John Black wrote:
I want sep="" to be the default without having to specify it every time I
call print. Is that possible?
John Black
Define a replacement print function that makes this the default.
Something like (untested, a detail may be wrong):
_print =
John Black wrote:
> I want sep="" to be the default without having to specify it every time I
> call print. Is that possible?
No, but you can replace the print function with your own:
>>> print = functools.partial(print, sep="")
>>> print("I
Le 09/10/2017 à 18:22, John Black a écrit :
I want sep="" to be the default without having to specify it every time I
call print. Is that possible?
>>> oldprint = print
>>> def print(*args,**kwargs):
... oldprint(*args,**kwargs,sep='')
...
>>> print(1,2,3)
123
--
https://mail.python.org/mail
On 9 October 2017 at 17:22, John Black wrote:
> I want sep="" to be the default without having to specify it every time I
> call print. Is that possible?
def myprint(*args, **kw):
print(*args, sep="", **kw)
If you want, assign print=myprint.
Paul
--
https://mail.python.org/mailman/listinf
On 10/9/17 12:22 PM, John Black wrote:
I want sep="" to be the default without having to specify it every time I
call print. Is that possible?
There isn't a way to change the default for print(sep="") globally.
Generally when you want better control over the output, you use string
formatti
I want sep="" to be the default without having to specify it every time I
call print. Is that possible?
John Black
--
https://mail.python.org/mailman/listinfo/python-list
On Sunday, October 2, 2016 at 2:12:39 AM UTC+1, 38016...@gmail.com wrote:
> I am trying to print a simple decision tree for my homework.
> The answer must keep in this format:
>
> Top 7,4,0.95
> career gain = 100
> 1.Management 2, 3, 0.9709505944546686
> 2.Service 5, 1, 0.6500224216483
在 2016年10月2日星期日 UTC-4下午1:05:58,Peter Pearson写道:
> On Sat, 1 Oct 2016 18:12:29 -0700 (PDT), 38016226...@gmail.com wrote:
> > I am trying to print a simple decision tree for my homework.
> > The answer must keep in this format:
> >
> > Top 7,4,0.95
> > career gain = 100
> > 1.Management 2, 3, 0.9
On Sat, 1 Oct 2016 18:12:29 -0700 (PDT), 38016226...@gmail.com wrote:
> I am trying to print a simple decision tree for my homework.
> The answer must keep in this format:
>
> Top 7,4,0.95
> career gain = 100
> 1.Management 2, 3, 0.9709505944546686
> 2.Service 5, 1, 0.6500224216483541
>
I am trying to print a simple decision tree for my homework.
The answer must keep in this format:
Top 7,4,0.95
career gain = 100
1.Management 2, 3, 0.9709505944546686
2.Service 5, 1, 0.6500224216483541
location gain = 100
1.Oregon 4, 1, 0.7219280948873623
2.Californ
On Thu, Aug 11, 2016 at 1:38 PM MRAB wrote:
> On 2016-08-11 18:18, Chris Angelico wrote:
> > On Fri, Aug 12, 2016 at 3:03 AM, Atri Mahapatra
> > wrote:
> >> I have installed IDLE 3.5.1 and wrote the following to check if print
> is working. When it runs, I do not see anything is printed:
> >>
>
On 2016-08-11 18:18, Chris Angelico wrote:
On Fri, Aug 12, 2016 at 3:03 AM, Atri Mahapatra
wrote:
I have installed IDLE 3.5.1 and wrote the following to check if print is
working. When it runs, I do not see anything is printed:
class Base: #{
def __init__( self ): #{
print("Hello
Atri Mahapatra wrote:
> I have installed IDLE 3.5.1 and wrote the following to check if print is
> working. When it runs, I do not see anything is printed:
>
> class Base: #{
> def __init__( self ): #{
> print("Hello, world: \n\n");
>
> #}
>
> #}
>
>
> if ( __name__ =
On Fri, Aug 12, 2016 at 3:03 AM, Atri Mahapatra
wrote:
> I have installed IDLE 3.5.1 and wrote the following to check if print is
> working. When it runs, I do not see anything is printed:
>
> class Base: #{
> def __init__( self ): #{
> print("Hello, world: \n\n");
>
> #}
>
>
I have installed IDLE 3.5.1 and wrote the following print command to see if it
is working. When I ran the code nothing is printed. Can you please point the
reason- anything wrong with the code?
class Base: #{
def __init__( self ): #{
print("Hello, world: \n\n");
#}
#}
I have installed IDLE 3.5.1 and wrote the following to check if print is
working. When it runs, I do not see anything is printed:
class Base: #{
def __init__( self ): #{
print("Hello, world: \n\n");
#}
#}
if ( __name__ == " __main__"): #{
root = Base();
#}
Can an
> You could use win_unicode_console enabled in sitecustomize or usercustomize.
> https://pypi.python.org/pypi/win_unicode_console
The pypi link you shared has an excellent summary of the issues
associated when working Unicode from the Windows terminal.
Thank you Eryk.
Malcolm
--
https://mail.py
On Wed, Aug 3, 2016 at 3:35 PM, Malcolm Greene wrote:
> But under Windows, the stdout is workstation specific and *never* UTF-8. So
> the
> occasional non-ASCII string trips up our diagnostic output when tested under
> Windows.
You could use win_unicode_console enabled in sitecustomize or usercu
Chris,
> Don't forget that the print function can simply be shadowed.
I did forget! Another excellent option. Thank you!
Malcolm
--
https://mail.python.org/mailman/listinfo/python-list
utput to the console with as few changes to the original scripts
> as possible, eg. non-invasive except for the print statements
> themselves.
Don't forget that the print function can simply be shadowed. If you
have a lot of code that uses print(...) to output text, and you want
to qui
Thank you Random832 and Peter - excellent ideas.
My use case was diagnostic output being (temporarily) output to stdout
via debug related print statements. The output is for debugging only and
not meant for production. I was looking for a solution that would allow
me to output to the console with
On Wed, Aug 3, 2016, at 11:09, Peter Otten wrote:
> I'm unsure about this myself -- wouldn't it be better to detach the
> underlying raw stream? Like
Well, "better" depends on your point of view.
> The ValueError raised if you try to write to the original stdout
> looks like a feature to me.
Ma
Random832 wrote:
> On Wed, Aug 3, 2016, at 08:29, Malcolm Greene wrote:
>> Looking for a way to use the Python 3 print() function with encoding and
>> errors parameters.
>> Are there any concerns with closing and re-opening sys.stdout so
>> sys.stdout has a specific e
On Wed, Aug 3, 2016, at 08:29, Malcolm Greene wrote:
> Looking for a way to use the Python 3 print() function with encoding and
> errors parameters.
>
> Are there any concerns with closing and re-opening sys.stdout so
> sys.stdout has a specific encoding and errors behavior? W
Looking for a way to use the Python 3 print() function with encoding and
errors parameters.
Are there any concerns with closing and re-opening sys.stdout so
sys.stdout has a specific encoding and errors behavior? Would this break
other standard libraries that depend on sys.stdout being configured
On Fri, Nov 14, 2014 at 9:58 PM, Steven D'Aprano
wrote:
> http://blog.codinghorror.com/why-cant-programmers-program/
>
> Not everyone agrees that this is a thing:
>
> http://www.skorks.com/2010/10/99-out-of-100-programmers-cant-program-i-call-bullshit/
>
> I'm inclined to accept that maybe 99 out
Chris Angelico wrote:
> There are blog posts out there about how large proportions of
> applicants can't even write simple code on command... and I've taken
> the questions and shown them to my siblings (who protest that they're
> definitely not programmers), proving that a basic smattering of
> m
"Clayton Kirkwood" writes:
> Although I suspect for a price you could bring all of your
> professional programming jobs to somebody here, but I think you
> would pay out more than you would make.
s/ here/ else/ and your assumption can be falsified
--
https://mail.python.org/mailman/listinfo/pyt
On Wed, Nov 12, 2014 at 4:39 PM, Clayton Kirkwood wrote:
> Chris, you're kidding, right? People get programming jobs without the
> knowledge? How do they keep them? Don't hiring people look at code examples,
> or previous employment? Ask relevant questions?
Oh, I didn't say they *keep* the jobs,
>-Original Message-
>From: Python-list [mailto:python-list-
>bounces+crk=godblessthe...@python.org] On Behalf Of Chris Angelico
>Sent: Tuesday, November 11, 2014 12:36 AM
>Cc: python-list@python.org
>Subject: Re: I don't read docs and don't know how to use
On Mon, 10 Nov 2014 21:36:54 +, Denis McMahon wrote:
> On Mon, 10 Nov 2014 10:56:18 -0800, sohcahtoa82 wrote:
>
>> ... I know software engineers make lots of money so I want to be one.
>
> I hear that pretty boy male escorts can make even more money than
> software engineers.
>
> They also
On Tue, Nov 11, 2014 at 10:21 AM, Clayton Kirkwood wrote:
> Uh, how are you going to maintain a programming job if you don't know how to
> program? I don't want to act but I know Brad Pitt makes lots of money doing
> it, so I want to be Brad Pitt. Not! Not going to happen. Although I suspect
> for
>-Original Message-
>From: Python-list [mailto:python-list-
>bounces+crk=godblessthe...@python.org] On Behalf Of Grant Edwards
>Sent: Monday, November 10, 2014 1:01 PM
>To: python-list@python.org
>Subject: Re: I don't read docs and don't know how to use
On 11/10/14 at 09:00pm, Grant Edwards wrote:
> That's the saddest troll I've seen in ages.
That, on the other hand, is a pretty decent bit of trolling.
--
https://mail.python.org/mailman/listinfo/python-list
On 2014-11-10 20:16, Ethan Furman wrote:
On 11/10/2014 11:59 AM, Larry Martell wrote:
On Mon, Nov 10, 2014 at 2:49 PM, Roy Smith wrote:
In article ,
sohcahto...@gmail.com wrote:
Please help me this assignment is due in an hour. Don't give me hints, just
give me the answer because I only w
On Mon, Nov 10, 2014 at 2:45 PM, wrote:
> On Monday, November 10, 2014 1:01:05 PM UTC-8, Grant Edwards wrote:
>> On 2014-11-10, sohcahtoa82 wrote:
>>
>> > Please help me this assignment is due in an hour. Don't give me
>> > hints, just give me the answer because I only want a grade. I'm not
>>
On Monday, November 10, 2014 1:01:05 PM UTC-8, Grant Edwards wrote:
> On 2014-11-10, sohcahtoa82 wrote:
>
> > Please help me this assignment is due in an hour. Don't give me
> > hints, just give me the answer because I only want a grade. I'm not
> > actually interested in learning how to progra
On Mon, 10 Nov 2014 10:56:18 -0800, sohcahtoa82 wrote:
> ... I know software engineers
> make lots of money so I want to be one.
I hear that pretty boy male escorts can make even more money than
software engineers.
They also don't need to learn how to program, which is something software
engin
On 2014-11-10, sohcahto...@gmail.com wrote:
> Please help me this assignment is due in an hour. Don't give me
> hints, just give me the answer because I only want a grade. I'm not
> actually interested in learning how to program, but I know software
> engineers make lots of money so I want to b
On 11/10/2014 11:59 AM, Larry Martell wrote:
On Mon, Nov 10, 2014 at 2:49 PM, Roy Smith wrote:
In article ,
sohcahto...@gmail.com wrote:
Please help me this assignment is due in an hour. Don't give me hints, just
give me the answer because I only want a grade. I'm not actually interested
On 10/11/2014 19:24, Peter Otten wrote:
sohcahto...@gmail.com wrote:
Please help me this assignment is due in an hour. Don't give me hints,
just give me the answer because I only want a grade. I'm not actually
interested in learning how to program, but I know software engineers make
lots of m
On Mon, Nov 10, 2014 at 2:49 PM, Roy Smith wrote:
> In article ,
> sohcahto...@gmail.com wrote:
>
>> Please help me this assignment is due in an hour. Don't give me hints, just
>> give me the answer because I only want a grade. I'm not actually interested
>> in learning how to program, but I kn
In article ,
sohcahto...@gmail.com wrote:
> Please help me this assignment is due in an hour. Don't give me hints, just
> give me the answer because I only want a grade. I'm not actually interested
> in learning how to program, but I know software engineers make lots of money
> so I want to
sohcahto...@gmail.com wrote:
> Please help me this assignment is due in an hour. Don't give me hints,
> just give me the answer because I only want a grade. I'm not actually
> interested in learning how to program, but I know software engineers make
> lots of money so I want to be one.
I'm sorr
Please help me this assignment is due in an hour. Don't give me hints, just
give me the answer because I only want a grade. I'm not actually interested in
learning how to program, but I know software engineers make lots of money so I
want to be one.
--
https://mail.python.org/mailman/listinfo
On Wed, Sep 11, 2013, at 07:36 AM, Wayne Werner wrote:
> On Sat, 31 Aug 2013, candide wrote:
> > # -
> > for i in range(5):
> >print(i, end=' ') # <- The last ' ' is unwanted
> > print()
> > # -
>
> Then why not define end='' instead?
On Sat, 31 Aug 2013, candide wrote:
# -
for i in range(5):
print(i, end=' ') # <- The last ' ' is unwanted
print()
# -
Then why not define end='' instead?
-W
--
https://mail.python.org/mailman/listinfo/python-list
On 8/31/2013 7:15 PM, Joshua Landau wrote:
On 31 August 2013 23:08, Chris Angelico wrote:
On Sun, Sep 1, 2013 at 1:43 AM, Oscar Benjamin
wrote:
On 31 August 2013 16:30, Chris Angelico wrote:
but doesn't solve all the cases (imagine a string or an iterator).
Similar but maybe simpler, and
On 31 August 2013 23:08, Chris Angelico wrote:
> On Sun, Sep 1, 2013 at 1:43 AM, Oscar Benjamin
> wrote:
>> On 31 August 2013 16:30, Chris Angelico wrote:
but doesn't solve all the cases (imagine a string or an iterator).
>>>
>>> Similar but maybe simpler, and copes with more arbitrary
On Sun, Sep 1, 2013 at 1:43 AM, Oscar Benjamin
wrote:
> On 31 August 2013 16:30, Chris Angelico wrote:
>>>
>>> but doesn't solve all the cases (imagine a string or an iterator).
>>
>> Similar but maybe simpler, and copes with more arbitrary iterables:
>>
>> it=iter(range(5))
>> print(next(it), en
Le 31/08/2013 15:59, Peter Otten a écrit :
To make it crystal clear, the above was to illustrate the algorithm used in
Python 2, not a suggestion.
Ok sorry, I misinterpreted.
> I still think you should live with a trailing space
Are you sure ? The following code
#
Le 31/08/2013 12:31, Peter Otten a écrit :
with `softspace` saved as a file attribute, is gone in Python3.
After reading
http://docs.python.org/3.0/whatsnew/3.0.html#print-is-a-function
I understand what you meant by "softspace". Thanks.
--
http://mail.python.org/mailman/listinfo/python-l
On 31 August 2013 16:30, Chris Angelico wrote:
>>
>> but doesn't solve all the cases (imagine a string or an iterator).
>
> Similar but maybe simpler, and copes with more arbitrary iterables:
>
> it=iter(range(5))
> print(next(it), end='')
> for i in it:
> print('',i, end='')
If you want to w
On Sat, Aug 31, 2013 at 11:33 PM, candide wrote:
> The if instruction imposes useless testing (we know in advance the problem
> to occur at the very end of the loop) and useless writing (writing '').
>
> The following is clearer
>
> # -
> n=5
> for i in range(n-1):
> pr
On Sat, 31 Aug 2013 14:59:17 +0200, candide wrote:
> Le 31/08/2013 13:16, Steven D'Aprano a écrit :
>
>
>> Of course it does. Have you actually tried it?
>
>
> Of course I did, redirecting the output to a file in order to spot an
> eventually trailing space. I did the same for the Python 3 cod
candide wrote:
> Le 31/08/2013 12:31, Peter Otten a écrit :
> > softspace = False
> > for i in range(5):
> > if softspace:
> > print(end=" ")
> > print(i, end="")
> > softspace = True
> > print()
>
>
> The if instruction imposes useless testing (we know in advance
Le 31/08/2013 13:24, Ned Batchelder a écrit :
For a beginner course, the trailing space is fine, use this code.
I was really expecting there was a trick but I'll follow your advice,
after all the trailing space is invisible!
Nevertheless, this can be quite annoying. For instance, some autom
Le 31/08/2013 12:31, Peter Otten a écrit :
> softspace = False
> for i in range(5):
> if softspace:
> print(end=" ")
> print(i, end="")
> softspace = True
> print()
The if instruction imposes useless testing (we know in advance the
problem to occur at the very end of the
Le 31/08/2013 13:16, Steven D'Aprano a écrit :
Of course it does. Have you actually tried it?
Of course I did, redirecting the output to a file in order to spot an
eventually trailing space. I did the same for the Python 3 code.
--
http://mail.python.org/mailman/listinfo/python-list
On 31 August 2013 12:16, Steven D'Aprano
wrote:
> On Sat, 31 Aug 2013 10:17:23 +0200, candide wrote:
>
>> What is the equivalent in Python 3 to the following Python 2 code:
>>
>> # -
>> for i in range(5):
>> print i,
>> # -
>>
>> ?
>>
>>
Steven D'Aprano wrote:
> On Sat, 31 Aug 2013 10:17:23 +0200, candide wrote:
>
>> What is the equivalent in Python 3 to the following Python 2 code:
>>
>> # -
>> for i in range(5):
>> print i,
>> # -
>>
>> ?
>>
>> Be careful that the
On 8/31/13 4:17 AM, candide wrote:
What is the equivalent in Python 3 to the following Python 2 code:
# -
for i in range(5):
print i,
# -
?
Be careful that the above code doesn't add a trailing space after the
last number in the lis
On Sat, 31 Aug 2013 10:17:23 +0200, candide wrote:
> What is the equivalent in Python 3 to the following Python 2 code:
>
> # -
> for i in range(5):
> print i,
> # -
>
> ?
>
> Be careful that the above code doesn't add a trailing spac
candide wrote:
> Le 31/08/2013 10:43, Andreas Perstinger a écrit :
>
> > How about
> >
> > >>> print(" ".join(str(i) for i in range(5)))
> > 0 1 2 3 4
> >
>
>
> Thanks for your answer. The output is stricly the same but the code
> doesn't suit my needs :
>
> 1) I'm porting to Python 3 a
Le 31/08/2013 10:43, Andreas Perstinger a écrit :
> How about
>
> >>> print(" ".join(str(i) for i in range(5)))
> 0 1 2 3 4
>
Thanks for your answer. The output is stricly the same but the code
doesn't suit my needs :
1) I'm porting to Python 3 a Python 2 full beginner course : the
learner
On 31.08.2013 10:17, candide wrote:
What is the equivalent in Python 3 to the following Python 2 code:
# -
for i in range(5):
print i,
# -
?
How about
>>> print(" ".join(str(i) for i in range(5)))
0 1 2 3 4
Bye, Andreas
--
ht
What is the equivalent in Python 3 to the following Python 2 code:
# -
for i in range(5):
print i,
# -
?
Be careful that the above code doesn't add a trailing space after the
last number in the list, hence the following Python 3 code
On Sat, 22 Sep 2012 01:26:43 +, Steven D'Aprano wrote:
> On Fri, 21 Sep 2012 13:20:09 -0700, gengyangcai wrote:
>
>> I am currently using Python 3.2.3 . WHen I use the print function by
>> typing print "Game Over" , it mentions " SyntaxError : inval
On 22/09/2012 02:26, Steven D'Aprano wrote:
On Fri, 21 Sep 2012 13:20:09 -0700, gengyangcai wrote:
I am currently using Python 3.2.3 . WHen I use the print function by
typing print "Game Over" , it mentions " SyntaxError : invalid syntax
". Any ideas on what the prob
On Fri, 21 Sep 2012 13:20:09 -0700, gengyangcai wrote:
> I am currently using Python 3.2.3 . WHen I use the print function by
> typing print "Game Over" , it mentions " SyntaxError : invalid syntax
> ". Any ideas on what the problem is and how to resolve it ?
N
On Fri, Sep 21, 2012 at 3:11 PM, Alister wrote:
> On Fri, 21 Sep 2012 14:54:14 -0600, Ian Kelly wrote:
>
>> On Fri, Sep 21, 2012 at 2:28 PM, Rodrick Brown
>> wrote:
>>> Go away troll!
>>
>> Troll? It looked like a sincere question to me.
>
> but one that page 1 of the documentation would answer.
In
gengyang...@gmail.com writes:
> I am currently using Python 3.2.3 . WHen I use the print function by
> typing print "Game Over" , it mentions " SyntaxError : invalid syntax ".
> Any ideas on what the problem is and how to resolve it ? Thanks a lot .
In python
On Fri, 21 Sep 2012 14:54:14 -0600, Ian Kelly wrote:
> On Fri, Sep 21, 2012 at 2:28 PM, Rodrick Brown
> wrote:
>> Go away troll!
>
> Troll? It looked like a sincere question to me.
but one that page 1 of the documentation would answer.
--
Waste not, get your budget cut next year.
--
http:/
On Fri, Sep 21, 2012 at 2:28 PM, Rodrick Brown wrote:
> Go away troll!
Troll? It looked like a sincere question to me.
--
http://mail.python.org/mailman/listinfo/python-list
Go away troll!
Sent from my iPhone
On Sep 21, 2012, at 4:27 PM, "gengyang...@gmail.com"
wrote:
> Hello ,
>
>
> I am currently using Python 3.2.3 . WHen I use the print function by typing
> print "Game Over" , it mentions " SyntaxError : invalid syntax
On 9/21/12 10:20 PM, gengyang...@gmail.com wrote:
Hello ,
I am currently using Python 3.2.3 . WHen I use the print function by typing print "Game
Over" , it mentions " SyntaxError : invalid syntax ". Any ideas on what the
problem is and how to resolve it ? Thanks a
Hello ,
I am currently using Python 3.2.3 . WHen I use the print function by typing
print "Game Over" , it mentions " SyntaxError : invalid syntax ". Any ideas
on what the problem is and how to resolve it ? Thanks a lot .
GengYang
--
http://mail.python.org/mailman/listinfo/python-list
On Fri, 2010-04-16 at 09:50 -0700, Dave W. wrote:
> >>> old_print = __builtins__.print
> >>> __builtins__.print = printhook
> >>> yield
> >>> __builtins__.print = old_print
> >
> >> I'm pretty sure this is semantically equivalent to my original
> >> code, but I gave it a try anyway.
>>> old_print = __builtins__.print
>>> __builtins__.print = printhook
>>> yield
>>> __builtins__.print = old_print
>
>> I'm pretty sure this is semantically equivalent to my original
>> code, but I gave it a try anyway.
>
> Not at all. Declaring "global print" then assigning to "pri
On 2010-04-15 21:17 PM, Dave W. wrote:
I naively thought I could capture output from exec()'ed print
invocations by (somehow) overriding 'print' globally. But this
seems not to be possible.
old_print = __builtins__.print
__builtins__.print = printhook
yield
__builtins__.print
lier...@compaq ~/junks $ python3 printhook.py
Python 3.1.2 (r312:79147, Apr 16 2010, 16:58:34)
[GCC 4.3.4]
linux2
Type "help", "copyright", "credits" or "license" for more info.
>>> print(32)
printhook(): 32
Note that assigning to __builtins__.p
Dave W. wrote:
> I naively thought I could capture output from exec()'ed print
> invocations by (somehow) overriding 'print' globally. But this
> seems not to be possible. Or at least not easy:
Assigning a new function to the global print name affects only print() calls
within your script, not
> > I naively thought I could capture output from exec()'ed print
> > invocations by (somehow) overriding 'print' globally. But this
> > seems not to be possible.
>
>old_print = __builtins__.print
>__builtins__.print = printhook
>yield
>__builtins__.print = old_print
I'm pretty
[MSC v.1500 32 bit
(Intel)] win32
Type "help", "copyright", "credits" or "license" for more info.
print("Hello?")
Hello?
My custom print function isn't being called (see code below),
I guess because its only being overridden in the cur
"help", "copyright", "credits" or "license" for more info.
>>> print("Hello?")
Hello?
>>>
My custom print function isn't being called (see code below),
I guess because its only being overridden in the current module?
Is ther
Dennis Lee Bieber wrote:
Does Python 3.x include SQLite?
Of course ;-]
>>> import sqlite3
>>> dir(sqlite3)
['Binary', 'Cache', 'Connection', 'Cursor', 'DataError',
[snip]
adapt', 'adapters', 'apilevel', 'complete_statement', 'connect',
'converters', 'datetime', 'dbapi2', 'enable_callback_tr
Anjanesh Lekshminarayanan wrote:
>> Maybe it would help if you explained what you are actually trying to
>> accomplish.
>
> import csv
> f = csv.reader(open('data.txt'), delimiter='\t') # 2GB text file
> sql = "INSERT INTO `data` VALUES (NULL,%s,%s,%s,%s,%s);"
> for row in f:
> print (sql, (r
> Maybe it would help if you explained what you are actually trying to
> accomplish.
import csv
f = csv.reader(open('data.txt'), delimiter='\t') # 2GB text file
sql = "INSERT INTO `data` VALUES (NULL,%s,%s,%s,%s,%s);"
for row in f:
print (sql, (row[0],row[1],row[2],row[3],row[4]))
$ python3 p
Anjanesh Lekshminarayanan wrote:
> As of now, there is no mysql adaptor for Python3. Hence cant use
> escape_string()
Maybe it would help if you explained what you are actually trying to
accomplish.
--
Carsten Haese
http://informixdb.sourceforge.net
--
http://mail.python.org/mailman/listinfo/p
As of now, there is no mysql adaptor for Python3. Hence cant use escape_string()
> I don't have the slightest clue what you want to say with that.
--
Anjanesh Lekshmnarayanan
--
http://mail.python.org/mailman/listinfo/python-list
Anjanesh Lekshminarayanan wrote:
>> Depending on your DB-adapter, you are out of luck here. Either connect to
>> a db even if you don't need it, or try & see if you can locate the
>> implementation in the module somehow.
>
> ImportError: No module named MySQLdb
> MySQLdb only available in Python2
> Depending on your DB-adapter, you are out of luck here. Either connect to a
> db even if you don't need it, or try & see if you can locate the
> implementation in the module somehow.
ImportError: No module named MySQLdb
MySQLdb only available in Python2.
--
Anjanesh Lekshmnarayanan
--
http:
Anjanesh Lekshminarayanan wrote:
> Python 3.1.1
>
> sql = "INSERT INTO `tbl` VALUES (NULL, '%s', '%s', '%s', '%s', '%s');"
> for row in fp:
> print (sql, (row[0],row[1],row[2],row[3],row[4]))
> .
> INSERT INTO `tbl` VALUES (NULL, '%s', '%s', '%s', '%s', '%s'); ('142',
> 'abc', '2006-04-09 02:
1 - 100 of 107 matches
Mail list logo