Hi Maxim,
If it's the trailing zeroes you're concerned about, here's a work-around:
('%.2f' % 10.5678).rstrip('0')
'10.57
I'm sure there are better solutions. But this one works for your need,
right?
Cheers,'
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335
Did no one notice that
for(i = 99; i 0; ++i)
Gives you an infinite loop (sort of) because i starts a 99, and increases
every loop?
Cheers,
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
Website: http
Weeble,
Try to use the full arguments of insert(i, x), instead of using list slices.
Every time you create a slice, Python copies the list into a new memory
location with the sliced copy. That's probably a big performance impact
there if done recursively.
My 2cp,
Xav
On Fri, Mar 19, 2010 at
rnfl gb rkcynva, vg znl or n tbbq vqrn.
Anzrfcnprf ner bar ubaxvat terng vqrn -- yrg'f qb zber bs gubfr!
And some other attributes in 'this' module as well, that decodes the string.
I'm curious. Was this encoded purely for fun? *grins*
Cheers,
Ching-Yun Xavier Ho, Technical Artist
Contact
I'm looking at your code and was thinking ... why writing code that is
difficult to understand?
To answer your question though, they're different because in case f, your
lambda experssion is only evaluated once. That means the variable 'n' is
ever only created once, and replaced repeatedly. In
I don't think it's a stupid question at all. =]. But wouldn't it solve the
problem if you call the generator the first time you need it to yield?
Cheers,
Xav
On Fri, Feb 19, 2010 at 9:30 AM, Robert Kern robert.k...@gmail.com wrote:
On Feb 18, 5:08 pm, Steven D'Aprano
I'm not sure what you're after. Are you after how to calculate the area? Or
are you trying to graph it? Or an analytical solution?
What do you mean by take out the intersection?
-Xav
On Thu, Feb 4, 2010 at 9:47 PM, Shashwat Anand anand.shash...@gmail.comwrote:
I wanted some general
It's an interesting problem. Never thought it was this difficult. I can't
account for all geometrical enumerations, but assuming all 4 circles
intersect, here's the solution for this particular senario. It's probably
not going to be useful to you since you're working on geometrical
approximations
Personally, I love the fact that I can type in 2**25 in the intepreter
without crashing my machine. ;)
Cheers,
-Xav
--
http://mail.python.org/mailman/listinfo/python-list
This may not answer your question directly, but have you thought about
ingoring the number at the end of these non-standard timezones? CDT is
Central Daylight-saving Timezone, while CST is Central Standard Timezone.
And you are correct they are -5 and -6 hours respectively. Does pytz know
about
Would it hurt if you put in some extra information?
http://www.timeanddate.com/library/abbreviations/timezones/
HTH,
-Xav
P.S: You, sir, have an awesome first name.
On Mon, Feb 1, 2010 at 1:57 AM, Skip Montanaro s...@pobox.com wrote:
Does pytz know about CDT and CST?
Nope...
Skip
--
Putting quotemarks around the path would be a good start, I think.
Cheers,
Xav
On Sun, Dec 20, 2009 at 11:40 PM, Ray Holt mrhol...@sbcglobal.net wrote:
Why am I getting an invalid syntax error on the following:
os.chdir(c:\\Python_Modules). The error message says the colon after c is
Yes, if you want instance variables that are unique to each instance of a
class, do the following:
class Parser:
def __init__(self):
self.items = []
And that should work fine.
J:\_Programming Projects\Pythonpython test.py
__main__.Parser object at 0x0240E7B0
__main__.Parser object at
On Fri, Dec 11, 2009 at 12:05 PM, Kevin Ar18 kevina...@hotmail.com wrote:
I am aware of the fact that you can somehow replace the __builtins__ in
Python. There is a library here that modifies the binary builtins:
http://github.com/aht/stream.py/blob/master/stream.py
Question: Is there
Hi Victor,
the .append function doesn't return anything, so it's a None. And you should
have it inside the parentheses.
tree.append(%s%s % (\t * level, name))
is probably what you're after.
Cheers,
Xav
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Nov 18, 2009 at 12:28 PM, Peng Yu pengyu...@gmail.com wrote:
I don't see any different between the following code in terms of
output. Are they exactly the same ('as' v.s. ',')?
Yes, they're exactly the same. However, the syntax with as is newer,
introducted in Python 3.x, and
On Tue, Nov 17, 2009 at 12:02 AM, Mr.SpOOn mr.spoo...@gmail.com wrote:
Hi,
I'm trying to use logical operators (or, and) with the in statement,
but I'm having some problems to understand their behavior.
Hey Carlo, I think your issue here is mistaking 'in' as a statement. It's
just another
On Tue, Nov 17, 2009 at 12:08 AM, Mr.SpOOn mr.spoo...@gmail.com wrote:
Sorry for replying to myself, but I think I understood why I was wrong.
The correct statement should be something like this:
In [13]: ('b3' and '5') in l or ('3' and 'b3') in l
Out[13]: True
Carlo, I'm not sure what
On Tue, Nov 17, 2009 at 12:46 AM, Chris Rebert c...@rebertia.com wrote:
On Mon, Nov 16, 2009 at 6:23 AM, Xavier Ho cont...@xavierho.com wrote:
AND operator has a higher precedence, so you don't need any brackets
here, I
think. But anyway, you have to use it like that. So that's something
On Sun, Nov 8, 2009 at 12:44 AM, Ray Holt mrhol...@sbcglobal.net wrote:
I have a assignment to write a program to compute and print the 1000th.
prime number. Can someone give me some leads on the correct code?
Ray, if you really want an answer out of this list, you'll have to at least
show
I don't have Python 25 on my computer, but since codepad.org is using Python
2.5.1, I did a quick test:
# input
try:
raise Exception(Mrraa!)
except Exception as msg:
print msg
# output
t.py:3: Warning: 'as' will become a reserved keyword in Python 2.6
Line 3
except Exception as
Alf, I kindly urge you to re-read bartc's comments. He does have a good
point and you seem to be avoiding direct answers.
On Fri, Oct 30, 2009 at 1:17 PM, Alf P. Steinbach al...@start.no wrote:
* bartc:
You say elsewhere that you're not specifically teaching Python, but the
text is full of
On Fri, Oct 30, 2009 at 1:48 PM, Alf P. Steinbach al...@start.no wrote:
Does that mean that 'print' is still subject to change as of 3.1.1?
Funny that. They removed reduce() when Python moved from 2.6.x to 3.0. They
even removed __cmp__(). Makes me a sad panda.
Is print() subject to change as
On Wed, Oct 21, 2009 at 6:11 PM, catalinf...@gmail.com
catalinf...@gmail.com wrote:
pass = md5.new()
File stdin, line 1
pass = md5.new()
^
SyntaxError: invalid syntax
pass is a keyword in Python, you can't use it as an identifier.
Try password instead.
Cheers,
Xav
--
On Thu, Oct 15, 2009 at 5:14 PM, Ole Streicher ole-usenet-s...@gmx.netwrote:
snip
So what is the reason that Python has separate __call__()/() and
__getitem__()/[] interfaces and what is the rule to choose between them?
Hi,
This is very interesting, a thought that never occured to me before.
On Fri, Oct 16, 2009 at 3:28 AM, Ander and...@hot.ee wrote:
I can't send emails out. Can u fix this problem please?
I don't know what I'm missing here, but you evidently sent out an email to
the Python mailing list...
Cheers,
Xav
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Oct 15, 2009 at 10:58 AM, Peng Yu pengyu...@gmail.com wrote:
I actually wanted to ask what return code should be returned in this
case when the arguments are not right. Thank you1
I think that depends on the design of the program. Is there a return value
that would make sense to be
On Mon, Oct 12, 2009 at 11:32 PM, Luis Zarrabeitia ky...@uh.cu wrote:
Actually, in python, this works even better:
for lin in iter(file_object.readline, ):
... do something with lin
What about
with open(path_string) as f:
for line in f:
# do something
Cheers,
Xav
--
On Fri, Sep 25, 2009 at 10:42 PM, Bahadir bilgehan.bal...@gmail.com wrote:
Hi there,
My question is simple, but I've been spending some hours over the web
and still struggling to get this right: How do I format a string that
contains single quotes in it?
I don't know what you're doing
On Thu, Sep 24, 2009 at 8:54 PM, Evora lasse_lorent...@hotmail.com wrote:
Hello,
I'm a bit of a newbie to python, so this may very well be a basic question:
I have a list of lists, with around 1000 lists looking like this:
['0.000744', '0.480106', 'B'].
I need the average of the first to
()) - default
loc = dict(locals())
for item in loc.items():
if item[0] in user:
print(item)
###output:
('a', __main__.test object at 0x02D6A240)
('default', {'__builtins__', '__name__', '__file__', '__doc__',
'__package__'})
('test', class '__main__.test')
Cheers,
Ching-Yun Xavier
On Thu, Sep 24, 2009 at 1:05 PM, MacRules macru...@none.com wrote:
s=1234abcd
s.range(0..4)
1234a
Is there a string function like this?
Use the slice.
s = 1234abcd
s[:5]
'1234a'
Cheers,
Xav
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Sep 22, 2009 at 11:58 PM, Mahmoud Abdelkader
mabdelka...@gmail.comwrote:
hi looking for help catching up in a class and overall to get me better
than i am now. I can pay you by the week or per hour.
Wow. I'd feel guilty getting paid doing that. Sounds all too easy.
I hope he is
On Mon, Sep 21, 2009 at 6:27 AM, daggerdvm dagger...@yahoo.com wrote:
Write the definition of a function twice , that receives an int
parameter and returns an int that is twice the value of the
parameter.
how can i do this
I thought it was easier to implement this twice function than
On Tue, Sep 15, 2009 at 9:47 PM, Lambda stephenh...@gmail.com wrote:
When I run it, it says TypeError: unhashable instance
I believe you need to implement __hash__() for the class. Make sure your
class returns a unique identifier for a certain value.
--
On Tue, Sep 15, 2009 at 10:31 PM, Ulrich Eckhardt
eckha...@satorlaser.comwrote:
'abc'.split('') gives me a ValueError: empty separator.
However, ''.join(['a', 'b', 'c']) gives me 'abc'.
Why this asymmetry? I was under the impression that the two would be
complementary.
I'm not sure about
Try
if __name__ == '__main__'
:],
Xav
On Mon, Sep 14, 2009 at 11:43 AM, Peng Yu pengyu...@gmail.com wrote:
Hi,
I try the following code. I don't quite understand why __main__ is not
defined. Could somebody let me know what I am wrong about it?
Regards,
Peng
$ cat test.py
This topic came up before. =] See below. Not sure how 'standardised' this
is, though.
Double precision:
import struct
struct.unpack('d', struct.pack('Q', 1))[0]
4.9406564584124654e-324
Float precision:
struct.unpack('f', struct.pack('L', 1))[0]
1.4012984643248171e-45
Cheers,
Xavier
--
On Tue, Sep 1, 2009 at 9:29 AM, Ecir Hana ecir.h...@gmail.com wrote:
- if I understood it correctly defining a function in the string and
exec-ing it created the function in current scope. This is something I
really don't want
Oops, missed that point.
May I ask what is there you don't want,
On Fri, Aug 28, 2009 at 5:45 PM, hoffik be...@seznam.cz wrote:
Hello,
I'm quite new in Python and I have one question. I have a 2D matrix of
values stored in list (3 columns, many rows). I wonder if I can select one
column without having to go through the list with 'for' command.
As far as
On Fri, Aug 28, 2009 at 6:18 PM, Hendrik van Rooyen hend...@microcorp.co.za
wrote:
It would really be nice if the reply would go to the list, but for the
digest versions, at least, it does not.
I'm on a few other lists. The Python ones are the only ones that I have to
manually change.
The
On Fri, Aug 28, 2009 at 6:54 PM, Ben Finney
ben+pyt...@benfinney.id.auben%2bpyt...@benfinney.id.au
wrote:
Fortunately, the messages that come from the list enable any mail client
to know the correct address for “reply to list”. It only remains to
choose a mail client that knows how to use it.
it, and what
for?
-
Kind regards,
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
Website: http://xavierho.com/
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, Aug 25, 2009 at 3:43 AM, Emanuele D'Arrigo man...@gmail.com wrote:
Let's say I have a list accessed by two threads, one removing list
items via del myList[index] statement the other iterating through
the list and printing out the items via for item in myList:
statement.
I tried
On Fri, Aug 28, 2009 at 9:49 AM, kj no.em...@please.post wrote:
Miles Kaufmann mile...@umich.edu writes:
...because the suite
namespace and the class namespace would get out of sync when different
objects were assigned to the class namespace:
class C:
x = 1
def foo(self):
On Fri, Aug 28, 2009 at 1:27 PM, Miles Kaufmann mile...@umich.edu wrote:
You're right, of course. If I had been thinking properly, I would have
posted this:
... the suite namespace and the class namespace would get out of sync when
different objects were assigned to the class namespace:
On Fri, Aug 28, 2009 at 1:48 PM, Xavier Ho cont...@xavierho.com wrote:
Class already provides some kind of scoping/namespace, that is the locals()
method for the class. What is pypothetical about this, if you could
elaborate?
Obviously that was supposed to be hypothetical. Oops.
--
http
On Fri, Aug 28, 2009 at 1:52 PM, Duke Normandin dukeofp...@ml1.net wrote:
How do I convert the contents of op from a string to an actual
arithmetic operator? eval() does not seem to be the answer. TIA!
Maybe you were looking for
print eval(num1 + op + num2) # it's a little ugly string
On Fri, Aug 28, 2009 at 2:35 PM, Ben Finney
ben+pyt...@benfinney.id.auben%2bpyt...@benfinney.id.au
wrote:
import operator
op_funcs = {
'+': operator.add,
'-': operator.sub,
'*': operator.mul,
'/': operator.div,
}
num_1 = int(raw_input('Enter
I haven't tested it, but did you encounter a problem defining __iadd__ in
the class definition?
See:
http://docs.python.org/reference/datamodel.html#object.__iadd__
Cheers,
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont
I'm not really quite sure what voodoo I did here, but my code seems to work
in Python 3.1.1 in the following way:
class Demo(object):
def func(self, n):
return n * 5
_f = func(None, 5)
d = Demo()
print(d._f)
print(d.func(5))
# OUTPUT
25
25
So, hmm?
Regards,
Ching-Yun Xavier
On Wed, Aug 26, 2009 at 2:14 AM, Diez B. Roggisch de...@nospam.web.dewrote:
Classes are not scopes.
So the above doesn't work because name resolution inside functions/methods
looks for local variables first, then for the *global* scope. There is no
class-scope-lookup.
Sorry, I'm coming
On Sun, Aug 23, 2009 at 9:26 PM, newbie sp.b...@gmail.com wrote:
Hi all
I'm interested in developing computer based, interactive programs for
students in a special school who have an aversion to pen and paper.
What sort of interactive program? Would it be educational, for example?
I've
On Sat, Aug 22, 2009 at 6:17 PM, flagmino ray.belan...@gmail.com wrote:
To get familiar with the debugger, I have loaded this program:
import math
def s1(x, y):
a = (x + y)
print(Answer from s1), a
return
def s2(x, y):
b = (x - y)
print(This comes from s2), b
#print z
On Thu, Aug 20, 2009 at 10:07 PM, Yan Jian ballack...@gmail.com wrote:
Does anyone encounter similar situation. Thank you for your help?
Yeah, in Python 3.1 I get this:
Traceback (most recent call last):
File test.py, line 6, in module
binhex.binhex(file, sys.stdout)
File
On Wed, Aug 19, 2009 at 5:57 PM, digisat...@gmail.com
digisat...@gmail.comwrote:
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type help, copyright, credits or license for more information.
' test\ttest'.expandtabs(4)
' test test'
'test
On Wed, Aug 19, 2009 at 7:00 PM, Horst Jäger h.jae...@medienkonzepte.dewrote:
Hi,
I would like to create my own lib hotte.py which I can import like
import string,hotte
. How do I do that?
1) Have the hotte.py in the same directory of any of your other Python code
that imports
On Sun, Aug 16, 2009 at 10:33 PM, Mark Lawrence breamore...@yahoo.co.ukwrote:
I wasn't discussing __cmp__, I was referring to the quote by Chris Rebert
from the Python docs regarding the rich comparison methods, a discrepancy
between the documentation and the implementation as noted in the
On Tue, Aug 18, 2009 at 2:45 PM, naveen naveen.g...@gmail.com wrote:
Is it possible to split up a class definition over multiple files?
-
Answer in short, I don't think so.
Now why would you want to do that?
There is another solution - have a main class for shared methods, and have
other
special methods, etc.
Also, I noticed heapq (the priority queue/heap queue module) doesn't use the
natural sorting order like sorted() does. Just saying. Could someone give it
a try?
Regards,
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
what I can come up with.
Thanks for the quick info.
Regards,
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
Website: http://xavierho.com/
--
http://mail.python.org/mailman/listinfo/python-list
apologise in advance.
Already googled around but I didn't find information on this.
Any replies appreciated.
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
Website: http://xavierho.com/
--
http://mail.python.org/mailman
-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
Website: http://xavierho.com/
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Aug 12, 2009 at 3:29 AM, Maria Liukis liu...@usc.edu wrote:
Hello everybody,
Is somebody aware of built-in Python's function that would return
a value for smallest positive double precision floating point number
(analogous to 'realmin' in Matlab). Python has built-in sys.maxint but I
I got it to work with Python 2.6.2.
import struct
struct.unpack('d', struct.pack('Q', 1))[0]
4.9406564584124654e-324
Python 3.1 will print 5e-324, which is fair enough.
Cheers,
Xavier
--
http://mail.python.org/mailman/listinfo/python-list
Actually, that was double precision. You asked for float precision.
struct.unpack('f', struct.pack('L', 1))[0]
1.4012984643248171e-45
which is the same as:
2**-149
1.4012984643248171e-45
I think that's it. Sorry for posting to the list three times in a row.
corrections welcome.
--
On Mon, Aug 10, 2009 at 10:41 PM, Christopher nadiasver...@gmail.comwrote:
Actually, it appears to be down again.
Nope, works for me, just a little slow.
-Xav
--
http://mail.python.org/mailman/listinfo/python-list
Well, it's back up now.
At least for me. ;)
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
Website: http://xavierho.com/
On Sun, Aug 9, 2009 at 4:49 AM, Sharath sharath20...@gmail.com wrote:
On Aug 8, 11:33
Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
Website: http://xavierho.com/
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Aug 6, 2009 at 1:19 PM, alex23 wuwe...@gmail.com wrote:
Xavier Ho wrote:
You should subclass collections.UserDict, and not the default dict class.
Refer to the collections module.
Xavier, why do you think that is the correct approach?
I'll be honest first and say that I do
]
# ...
Should do what you need.
Best regards,
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
Website: http://xavierho.com/
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Aug 5, 2009 at 10:50 PM, kpal kpalamartch...@gmail.com wrote:
Hello Everybody,
The standard datetime has 1 microsecond granularity. My application
needs finer time resolution, preferably float seconds. Is there an
alternative to the out-of-the-box datetime? Timezone support is not
might be of your interest.
Another guy have reported me that he experiences similar problems with
subclassing builtin 'list'.
Similarly, UserList is what you should subclass.
HTH,
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email
On Thu, Aug 6, 2009 at 5:23 AM, Joshua Kugler jos...@joshuakugler.comwrote:
Are you referring to Python 3.0? Python 2.6 does not have
collections.UserDict
j
Yes, I was sometimes it's hard to keep track what's not in 2.6 and in
3.1 for me, sorry. And thanks.
The ABC MutableMapping is
, some people have suggested to use that inside Python. That would work,
right?
Although, if you're just trying to find the Python-equivalent, fair enough.
Regards,
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
5GB of pictures
every time you access Maps - that wouldn't have worked. They work with the
only visible areas.
If you could tell us exactly what your program is trying to achieve, maybe
we'll have a better solution for you.
Best regards,
Ching-Yun Xavier Ho, Technical Artist
Contact Information
On Tue, Aug 4, 2009 at 8:30 PM, Yinon Ehrlich yinon...@gmail.com wrote:
Hi,
Easy way to test for Python version:
if sys.hexversion = 0x2060100:
pass
Great suggestion. I just tested it on my newly installed Python 3.1 (as of
3.1r31)
import sys
%X % sys.hexversion
'30100F0'
That's genius
On Tue, Aug 4, 2009 at 9:34 PM, Xavier Ho cont...@xavierho.com wrote:
... and '00F0' is r31!
Actually, 00F0 is 576 in decimal. Maybe it's the subversion?
Anyhow, it's still good!
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Aug 5, 2009 at 12:17 AM, MRAB pyt...@mrabarnett.plus.com wrote:
0x00F0 is 240.
... Right. I wonder where my brain is. *searches pocket*
So, what am I doing wrong here?
int(str(0x00F0), 16)
576
Cheers,
-Xav
--
http://mail.python.org/mailman/listinfo/python-list
On Wed, Aug 5, 2009 at 12:44 AM, D'Arcy J.M. Cain da...@druid.net wrote:
On Wed, 5 Aug 2009 00:39:56 +1000
Xavier Ho cont...@xavierho.com wrote:
So, what am I doing wrong here?
int(str(0x00F0), 16)
Look at the output of str(0x00F0) for a clue.
... Wow. I *am* slow tonight. Thanks
Whoops, posted to the wrong address yet again.
I deserve some punishment.
On Fri, Jul 31, 2009 at 5:33 PM, Xavier Ho cont...@xavierho.com wrote:
On Fri, Jul 31, 2009 at 5:25 PM, MalC0de malc0de.encr...@gmail.comwrote:
while true :
where's the problem,
There. =]
(Btw, it's True
On Fri, Jul 31, 2009 at 6:08 PM, Masklinn maskl...@masklinn.net wrote:
snip... but since Python doesn't have anonymous functions that usage
tends to be a bit too verbose ... snip
Sorry to interrupt, but wouldn't lambda in Python be considered as
'anonymous functions'?
--
On Fri, Jul 31, 2009 at 6:25 PM, Chris Rebert c...@rebertia.com wrote:
I believe full anonymous functions was intended by the author.
lambdas are limited to a single expression. Full anonymous functions
would be allowed to contain multiple statements.
Cheers, but what about this:
def
On Fri, Jul 31, 2009 at 6:38 PM, Chris Rebert c...@rebertia.com wrote:
No, because it has a name, namely goBig; this obviously prevents it
from being anonymous.
For comparison, note how the function in the following example is
never given a name, and is thus anonymous:
(lambda x: x+5)(6)
On Fri, Jul 31, 2009 at 7:25 PM, learner learner pyvault...@gmail.comwrote:
Hi all,
I want to compare two text files line by line and eliminate the
matching/repeated line and store the unmatched/leftout lines into a third
file or overwrite into one of them.
Sounds like homework to me. Why
superpollo wrote:
for (i, e) in enumerate(nomi):
print i, -, e
Just to be random:
print '\n'.join([%s - %s % (i, e) for i, e in enumerate(nomi)])
This has one advantage: only print once. So it's slightly faster if you have
a list of a large amount.
--
On Wed, Jul 29, 2009 at 8:52 PM, MRAB pyt...@mrabarnett.plus.com wrote:
Slightly shorter:
print '\n'.join(%s - %s % p for p in enumerate(nomi))
:-)
That's cool. Does that make the list a tuple? (not that it matters, I'm
just curious!)
I just tested for a list of 1000 elements (number in
Ack, sent to the wrong email again.
On Wed, Jul 29, 2009 at 9:02 PM, superpollo u...@example.net wrote:
print '\n'.join(%s - %s % p for p in enumerate(nomi))
File stdin, line 1
print '\n'.join(%s - %s % p for p in enumerate(nomi))
^
SyntaxError:
On Wed, Jul 29, 2009 at 9:17 PM, MRAB pyt...@mrabarnett.plus.com wrote:
I've just replaced the list comprehension with a generator expression.
Oh, and that isn't in Python 2.3 I see. Generators are slightly newer,
eh.
Thanks!
--
http://mail.python.org/mailman/listinfo/python-list
Is this a spam? Why did you have to send it 4 times, and it's already in the
past (July 9 and 10) ?
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
Website: http://xavierho.com/
--
http://mail.python.org/mailman
.
Good luck,
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
Website: http://xavierho.com/
--
http://mail.python.org/mailman/listinfo/python-list
problem.
Good luck. Any ideas appreciated.
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
Website: http://xavierho.com/
--
http://mail.python.org/mailman/listinfo/python-list
val('self.' + attr + '=\'' + val + '\'')
Obviously that was eval, not val. Also it doesn't work without the escaped
single quotes, either.
--
http://mail.python.org/mailman/listinfo/python-list
Got it:
exec('self.' + attr + '=\'' + val + '\'')
That worked. I think it'll do what you want now ;)
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
Website: http://xavierho.com/
--
http://mail.python.org
What is the point of the _SetVar method?
So you can set any variable in that class, I guess?
--
http://mail.python.org/mailman/listinfo/python-list
True has a bad reputation.
But mostly outside influences.
But if it's okay, it's okay by me.. I can't think of an easier way to code
the try loop above, anyhow.
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
as the previous version, but slightly safer on my
part... and I can adapt this in my future coding habits.
Thanks again.
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
Website: http://xavierho.com/
--
http://mail.python.org
just gave the link's code a quick try. It was at least 10x times
faster than my code to generate 10 prime numbers - I'll have a closer
look.
Thanks a great deal.
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
.
If you insists on using a try-except clause, use it this way:
Well, I don't have to use try-except. I think I got another idea though. I
could use an internal counter to keep track of how many prime numbers have
generated, and if not enough, generate more.
Thanks.
Ching-Yun Xavier Ho
() would be a better choice?
Best regards,
Ching-Yun Xavier Ho, Technical Artist
Contact Information
Mobile: (+61) 04 3335 4748
Skype ID: SpaXe85
Email: cont...@xavierho.com
Website: http://xavierho.com/
--
http://mail.python.org/mailman/listinfo/python-list
101 - 200 of 216 matches
Mail list logo