Re: python class instantiation

2006-10-23 Thread Chetan
Éric Daigneault wrote:
>Got a question for you all...
>
>I noticed a behaviour in python class creation that is strange, to say the
>least.
>
>When creating a class with data members but no __init__ method.  Python deals
>differently with data members that are muatable and immutables.
>
>Ex:
>class A(object):
>stringData = "Whatever"
>listData = []
>
>instance = A()
>
>Will have data members instantiated as expected (instance.stringData ==
>"Whatever" and instance.listData == [])
>
>instance.listData.append("SomeString")
>instance.stringData = "Changed"
>
>Now if I do
>
>secondInstance = A()
>
>it will come with the listData containing the SomeString appended to the
>instance...
>
>this is clearly not normal
>
>Especially that the stringData of Second instance contains the "Whatever" text.
>If the behaviour was at least consistant...  but it is not...
>
>Am I coing nuts or is this by desing, if so it is very misleading...  The two
>instances are sharing the same list, but not the same string ...  I did not
>declare the list to be static in any way  Why does it behave like this ?
>
>Éric
This is not what I get :
Here is the code and the output for 2.5
class A(object):
stringData = "Whatever"
listData = []

inst = A()

print inst.stringData
print inst.listData
print

inst.listData.append("SomeString")
inst.stringData = "Changed"

inst2 = A()

print inst2.stringData
print inst2.listData
print

inst.listData.append("NewThing")
inst.stringData = "NewChanged"

print inst.stringData
print inst.listData
print inst.stringData
print inst.listData
print

-
Whatever
[]

Whatever
['SomeString']

NewChanged
['SomeString', 'NewThing']
NewChanged
['SomeString', 'NewThing']

Isn't this what you got?

-Chetan
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Python thread stack size

2006-10-23 Thread Chetan
The default thread allocated in for pthread is 32K if the system default is
lower (it is 16K on my system). If the system default is higher, it is used.

-Chetan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: return tuple from C to python (extending python)

2006-10-24 Thread Chetan
"Kiran" <[EMAIL PROTECTED]> writes:

> PyObject* toRet;
> toRet = PyTuple_New(num_addr);
>
> then, in a for loop, i assign values to the tuple as follows:
>
> for ( i = 0; i < num_addr; i++ )
> {
> printf("%d\n", dat[i]);
> PyTuple_SET_ITEM(toRet, i, (PyObject*)dat[i] );
> }
> (dat is declared as follows: unsigned int* dat; )
>
> then, i say return toRet at the end of my C function.
>
> when I try to print the tuple in python, it says the memory address
> 0x could not be written, and I can see a part of the tuple
> printout, which is as follows:
> ( ,
> then i get my error.
>
You could use PyInt_From functions to convert dat[i] to PyInt
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ctypes Error: Why can't it find the DLL.

2006-10-24 Thread Chetan
"Mudcat" <[EMAIL PROTECTED]> writes:

Is the DLL loadable from a standalone C program?
All that is needed is a call to LoadLibrary() and check the return.

If the full path is not specified, the dll is searched in the predefined order
- I believe it is
  executable directory - in this case, directory of python.exe
  current directory- set the current drive and path to whereever you want
 before trying to load the dll
  windows system directory
  windows directory
  Directories specified in PATH evnvironment variable

-Chetan

> Hi,
>
> I can't figure out why ctypes won't load the DLL I need to use. I've
> tried everything I can find (and the ctypes website is down at the
> moment). Here's what I've seen so far.
>
> I've added the file arapi51.dll to the system32 directory.  However
> when I tried to access it I see this:
>
>>>> print windll.arapi51 # doctest: +WINDOWS
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "C:\Python24\Lib\site-packages\ctypes\__init__.py", line 387, in
> __getattr__
> dll = self._dlltype(name)
>   File "C:\Python24\Lib\site-packages\ctypes\__init__.py", line 312, in
> __init__
> self._handle = _dlopen(self._name, mode)
> WindowsError: [Errno 126] The specified module could not be found
>
> So then I use the find_library function, and it finds it:
>
>>>> find_library('arapi51.dll')
> 'C:\\WINNT\\system32\\arapi51.dll'
>
> At that point I try to use the LoadLibrary function, but it still can't
> find it:
>
>>>> windll.LoadLibrary('C:\WINNT\system32\arapi51.dll')
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "C:\Python24\Lib\site-packages\ctypes\__init__.py", line 395, in
> LoadLibrary
> return self._dlltype(name)
>   File "C:\Python24\Lib\site-packages\ctypes\__init__.py", line 312, in
> __init__
> self._handle = _dlopen(self._name, mode)
> WindowsError: [Errno 126] The specified module could not be found
>
> What am I doing wrong? I've used ctypes before and not had this
> problem. Before, I've just added the file to the system32 directory and
> not had this problem.
>
> On another note, if I wanted to include these DLL's to be a part of an
> installable package, how would I configure ctypes to use DLL's from a
> local directory?
>
> Thanks,
> Marc
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ctypes Error: Why can't it find the DLL.

2006-10-25 Thread Chetan
"Jon Clements" <[EMAIL PROTECTED]> writes:

> Mudcat wrote:
> 
> 
> > So then I use the find_library function, and it finds it:
> >
> > >>> find_library('arapi51.dll')
> > 'C:\\WINNT\\system32\\arapi51.dll'
> >
> 
> Notice it's escaped the '\' character.
> 
> > At that point I try to use the LoadLibrary function, but it still can't
> > find it:
> >
> > >>> windll.LoadLibrary('C:\WINNT\system32\arapi51.dll')
> > Traceback (most recent call last):
> >   File "", line 1, in ?
> >   File "C:\Python24\Lib\site-packages\ctypes\__init__.py", line 395, in
> > LoadLibrary
> > return self._dlltype(name)
> >   File "C:\Python24\Lib\site-packages\ctypes\__init__.py", line 312, in
> > __init__
> > self._handle = _dlopen(self._name, mode)
> > WindowsError: [Errno 126] The specified module could not be found
> >
> > What am I doing wrong? [snip]
> 
> You need to use either
> windll.LoadLibrary(r'c:\winnt\system32\arapi51.dll') or escape the \'s
> as the find_library function did. You're getting caught out by \a which
> is the alert/bell character. \w and \s aren't valid escape sequences so
> you get away with them. I'm guessing it's worked before because you've
> been lucky.
> 
> Works fine!:
> >>> 'C:\winnt\system32\smtpctrs.dll'
> 'C:\\winnt\\system32\\smtpctrs.dll'
> 
> Uh oh, escaped:
> >>> 'C:\winnt\system32\arapi51.dll'
> 'C:\\winnt\\system32\x07rapi51.dll'
I wondered about it, but that would not explain why it fails in the first case
- perhaps the OP now knows what happened. Interestingly I get a different
error with the distribution binary for 2.5 - I get "Error 22" instead of "Errno
126", but the message text was same, so I assumed this was from a different 
version and something had changed about how the errno is reported. 

However, I checked the windows error codes and 126 seems to be the correct
error. The error code talks about bad command and the corresponding message
text reads "The device does not recognize the command."

-Chetan

> 
> Jon.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fatal Python error: deallocating None

2006-10-25 Thread Chetan
"Delaney, Timothy (Tim)" <[EMAIL PROTECTED]> writes:

> George Sakkis wrote:
> 
> > What makes the problem worse is that it's not deterministic; I can
> > restart it from (a little before) the point of crash and it doesn't
> > happen again at the same point, but it might happen further down. Now,
> > I wouldn't mind restarting it manually every time since the crashes
> > are not all that frequent; problem is, it's supposed to be a
> > long-running process that will probably take days to finish normally,
> > so I want it to run overnight too. Any hints ?
> 
> None should *never* be deallocated, so it sounds like it's not being
> INCREFed correctly somewhere. Extension module, etc ...
> 
> Tim Delaney
Or incorrectly DECREFed, perhaps?

-Chetan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using mmap on large (> 2 Gig) files

2006-10-26 Thread Chetan
Paul Rubin <http://[EMAIL PROTECTED]> writes:

> "sturlamolden" <[EMAIL PROTECTED]> writes:
>> However, "memory mapping" a file by means of fseek() is probably more
>> efficient than using UNIX' mmap() or Windows'
>> CreateFileMapping()/MapViewOfFile().
>
> Why on would you think that?!  It is counterintuitive.  fseek beyond
> whatever is buffered in stdio (usually no more than 1kbyte or so)
> requires a system call, while mmap is just a memory access.
And the buffer copy required with every I/O from/to the application. 

>> In Python, we don't always need the file memory mapped, we normally
>> just want to use slicing-operators, for-loops and other goodies on
>> the file object -- i.e. we just want to treat the file as a Python
>> container object. There are many ways of achieving that.
>
> Some of the time we want to share the region with other processes.
> Sometimes we just want random access to a big file on disk without
> having to do a lot of context switches seeking around in the file.
>
>> There are in any case room for improving Python's mmap object.
>
> IMO it should have some kind of IPC locking mechanism added, in
> addition to the offset stuff suggested.
The type of IPC required differs depending on who is using the shared region -
either another python process or another external program. Apart from the
spinlock primitives, other types of synchronization mechanisms are provided by
the OS. However, I do see value in providing a shared memory based spinlock
mechanism. These services can be built on top of the shared memory
infrastructure. I am not sure what kind or real world python applications use
it. 

-Chetan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: To remove some lines from a file

2006-10-26 Thread Chetan
Sebastian Busch <[EMAIL PROTECTED]> writes:

> Steve Holden wrote:
>> Sebastian Busch wrote:
>>> [EMAIL PROTECTED] wrote:
>>>> ... I would like to remove two lines from a file. ...
>>> ... grep -v ...
>> ... show ...
>
> grep -v "`grep -v "commentsymbol" yourfile | head -2`" yourfile
>
>
> i frankly admit that there is also 'head' invoved ;)
>
> i really have no idea -- but i always thought that these coreutils and
> colleagues do their jobs as fast as possible, in particular faster than
> interpreted languages... however, as i posted last time, i was actually
> not aware that you have to call three of them.
>
> sebastian.
I don't have the original post to know exactly what is needed, but looks like
something that can be done by a single sed script. 

-Chetan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using mmap on large (> 2 Gig) files

2006-10-26 Thread Chetan
Paul Rubin  writes:

> I mean just have an interface to OS locks (Linux futex and whatever
> the Windows counterpart is) and maybe also a utility function to do a
> compare-and-swap in user space.
There is code for spinlocks, but it allocates the lockword in the process
memory. This can be used for thread synchronization, but not for IPC with
external python or non-python processes.
I found a PyIPC IPC package that seems to provide interface to Sys V shared
memory and semaphore  - but I just found it, so cannot comment on it at this
time.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using mmap on large (> 2 Gig) files

2006-10-28 Thread Chetan
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:

> Martin v. Löwis wrote:
> > sturlamolden schrieb:
> >
> > > And why doesn't Python's mmap take an offset argument to handle large
> > > files?
> >
> > I don't know exactly; the most likely reason is that nobody has
> > contributed code to make it support that. That's, in turn, probably
> > because nobody had the problem yet, or nobody of those who did
> > cared enough to implement and contribute a patch.
> 
> Or because no one cared enough to test a patch that was produced 2.5
> years ago (not directed at Martin, just pointing out why the patch
> stalled).
> 
>   http://python.org/sf/708374
> 
> With just a little community support, this can go in.  I suppose now
> that we have the buildbots, we can check in untested code and test it
> that way.  The patch should be reviewed.
> 
> n
I made the changes before I saw this. However, the patch seems to be quite
dated and some of the changes are very interesting, especially if they were
tested for the special conditions they are supposed to handle and 
if they were made after some discussion. 
I can submit my patch as it is, but I am working on making some of the other
changes I had in mind for the mmap to be useful.
Some of the other changes would make more sense for py3k, if it supports a byte
array object, but I haven't looked at py3k at all.

Chetan
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: PROBLEM with MOD_PYTHON

2006-10-28 Thread Chetan
"dan84" <[EMAIL PROTECTED]> writes:
> I don't understand this error , in the (Apache) errorlog I read this
> message :
> 
> [Sat Oct 28 14:04:03 2006] [error] make_obcallback: could not import
> mod_python.apache.\n
> [Sat Oct 28 14:04:03 2006] [error] make_obcallback: Python path being
> used "['C:Python24python24.zip', '.DLLs', '.lib',
> '.libplat-win', '.liblib-tk',
> 'C:ProgrammiApache GroupApache2bin']".
> [Sat Oct 28 14:04:03 2006] [error] python_handler: no interpreter
> callback found.
> [Sat Oct 28 14:04:03 2006] [error] [client 127.0.0.1] python_handler:
> Can't get/create interpreter.
> 
> I have Apache/2.0.59 (Win32) mod_python/3.2.10 Python/2.4.3
> I have read all the manuals, but I don't understand where I am wrong.
> 
> thanks so much
>Marco.
Even if there is nothing Apache specific, doesn't it look odd that the
path has 4 backslashes? Even accounting for half of those being added at the
time of printing, it would appear that Apache is trying to use the path that 
contains two backslashes as path separator but there needs to be only one. 

Chetan

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Safely renaming a file without overwriting

2006-10-28 Thread Chetan
Steven D'Aprano <[EMAIL PROTECTED]> writes:

> I want to rename a file, but only if the destination file name doesn't
> already exist.
> 
> I can do this:
> 
> if os.path.exists(dest):
> # skip file, raise an exception, make a backup...
> do_something_else() 
> else:
> os.rename(src, dest)
> 
> 
> But on a multi-user system, it is possible that dest is created in the
> time period between checking if it exists and attempting the rename.
> 
> Is there any way to prevent this? Or do I just try to keep the check and
> the rename as close together as possible, minimizing the chances and
> hoping for the best?
> 
> 
> -- 
> Steven.

The answer, unfortunately, depends on the platform. I haven't tried, but it
looks like rename() will fail on Win32 if the file already exists. On Unix, you
can use link to rename the file - which will not overwrite the file if it
exists. Then use unlink to remove the src file.

Chetan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: question about True values

2006-10-28 Thread Chetan
> Steven D'Aprano wrote:
> > On Sat, 28 Oct 2006 03:13:42 +0100, Steve Holden wrote:
>  >
> >>> Finally, while True/False is a good mental mapping for numeric 
> >>> comparisons,
> >>> take the following:
> >>>
> >>>  >>> if "Cliff is a pillar of the open source community":
> >>>   print "thank you"
> >>>  else:
> >>>   print "bugger off"
> >>>
> >>> bugger off
> >>>
> 
> First off, even though nobody has called me on it, this example really prints
> "thank you", not "bugger off".  I got confused in my cutting and pasting.
> Sorry about that.
> 
> 
> >>> Clearly this is not true.  (Google Cliff/Dyer open source: only 11 hits.),
> >>> but the string is *something* so the if block gets evaluated.
> >>>
> >>   >>> if "The above example was bollocks":
> >>   ...   print "You don't know what you are talking about"
> >>   ... else:
> >>   ...   print "Sorry: of course you are perfectly correct"
> >>   ...
> >> You don't know what you are talking about
> > Cliff is making a point about semantics, and he's absolutely correct about
> > it, although it is irrelevant since we're talking about two-value logic
> > not semantics.
> Cheers,
> Cliff

I am joining after some network downtime here, so I seem to have missed what
the real issue here is. At the risk of being completely irrelevant to the 
discussion here, I think it doesn't seem to be just about something or 
nothing - is None something or nothing? It seems to be neither:

>>> None
>>> None and True
>>> None or True
True
>>> None and False
>>> None or False
False
>>> False or None
>>> False and None
False
>>> True and None
>>> True or None
True
>>> not None
True

Chetan
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: question about True values

2006-10-28 Thread Chetan
Gabriel Genellina <[EMAIL PROTECTED]> writes:

> At Friday 27/10/2006 23:13, Steve Holden wrote:
>
>>J. Clifford Dyer wrote:
>> > the one thing that Ms. Creighton points out that I can't get past is
>> > that Python, even with its bool type, *still* evaluates somethingness
>> > and nothingness, and True and False are just numbers with hats on.
>> >
>> >  >>> True + 3
>> > 4
>> >  >>> bool(True-1)
>> > False
>> >  >>> bool(True-2)
>> > True
>> >  >>> (10 > 5) + (10 < 5)
>> > 1
>>Seems pretty clear to me that the situations you discuss above involve
>>numeric coercions of a Boolean value.
>
> A "true" Boolean value should not be coerced into any other thing. True+1 is 
> as
> meaningless as "A"+1, or even "1"+1. The fact is, bool is just an integer in
> disguise.
> I always regretted that Python just went mid-way moving onto a true Boolean
> type; I'd prefer it to stay as it was before bool was introduced.
>
>> > Python is not evaluating the truth of the matter, but, as Ms. Creighton
>> > would say, the "somethingness" of that which 10 > 5 evaluates to.  (1
>> > aka True)
>> >
>>   >>> type(10>5)
>>
>>   >>>
>
>>>> bool.__mro__
> (, , )
>
>>It does seem that there is a specific type associated with the result of
>>a comparison, even though you would really like to to be "a number with
>>a hat on".
>
> It *is* an integer with a hat on.
>
>>>> isinstance(True,int)
> True
This has focussed on the relational operators, which seem to produce a number
with a hat on. However, logical operations do not do so. 
True and "This string" produces "This string", for example.

This is hardly surprising, though.
The way they are defined, booleans seem to be the syntactic sugar that some 
people like. Many of the projects that I have been associated with had such
a define because the language (C) does not provide it. On the other hand, 
there are many who do just fine without them. 

For expressions used in control flow, if the expression somehow produces a 0
(False included) or None, the behavior is as if the expression is false. 
Confusion may arise because the way that answer is produced may not be
immediately obvious. For constructs such as "if obj:" the answer depends on
which methods the object has defined and what the state of the object is at the
time, but this has nothing to do with whether the answer that was produced was
strictly a boolean or not.

Chetan

>
>
> -- 
> Gabriel Genellina
> Softlab SRL 
>
> __
> Correo Yahoo!
> Espacio para todos tus mensajes, antivirus y antispam ¡gratis! ¡Abrí tu cuenta
> ya! - http://correo.yahoo.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: question about True values

2006-10-28 Thread Chetan
Georg Brandl <[EMAIL PROTECTED]> writes:

> Chetan wrote:
>>> Steven D'Aprano wrote:
>>> > On Sat, 28 Oct 2006 03:13:42 +0100, Steve Holden wrote:
>>>  >
>>> >>> Finally, while True/False is a good mental mapping for numeric 
>>> >>> comparisons,
>>> >>> take the following:
>>> >>>
>>> >>>  >>> if "Cliff is a pillar of the open source community":
>>> >>> print "thank you"
>>> >>>  else:
>>> >>> print "bugger off"
>>> >>>
>>> >>> bugger off
>>> >>>
>>>
>>> First off, even though nobody has called me on it, this example really 
>>> prints
>>> "thank you", not "bugger off".  I got confused in my cutting and pasting.
>>> Sorry about that.
>>>
>>>
>>> >>> Clearly this is not true.  (Google Cliff/Dyer open source: only 11 
>>> >>> hits.),
>>> >>> but the string is *something* so the if block gets evaluated.
>>> >>>
>>> >>   >>> if "The above example was bollocks":
>>> >>   ...   print "You don't know what you are talking about"
>>> >>   ... else:
>>> >>   ...   print "Sorry: of course you are perfectly correct"
>>> >>   ...
>>> >> You don't know what you are talking about
>>> > Cliff is making a point about semantics, and he's absolutely correct about
>>> > it, although it is irrelevant since we're talking about two-value logic
>>> > not semantics.
>>> Cheers,
>>> Cliff
>>
>> I am joining after some network downtime here, so I seem to have missed what
>> the real issue here is. At the risk of being completely irrelevant to the
>> discussion here, I think it doesn't seem to be just about something or
>> nothing - is None something or nothing? It seems to be neither:
>
> If is, of course, nothing. You may have misunderstood the semantics of the
> "and" and "or" operators.

I have not. I just posted another message on the subject. All I am trying to
point out is that the "nothingness" evaluation does not occur at the level of
expressions. It is only when the expression is needed to make decisions about
control flow that this comes into picture. 

>>>>> None
>>>>> None and True
>>>>> None or True
>> True
>>>>> None and False
>>>>> None or False
>> False
>>>>> False or None
>>>>> False and None
>> False
>>>>> True and None
>>>>> True or None
>> True
>>>>> not None
>> True
>
> x and y | x something | x nothing
> ---
> y something | y   | x
> y nothing   | y   | x
>
> x or y  | x something | x nothing
> ---
> y something | x   | y
> y nothing   | x   | y
>
>
> Georg
-- 
http://mail.python.org/mailman/listinfo/python-list


Algorithms in Python

2012-01-25 Thread Chetan Harjani
Is there any book or site on python algorithms which asks more and
teaches less, I don't want to get bored, and at the same time I want
to learn and act more. I use ubuntu. (just in case if its needed).
#ALGORITHMS



--
Chetan H Harjani
IIT Delhi
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Algorithms in Python

2012-01-25 Thread Chetan Harjani
Thanks Alec for the link. U know I wanted to read this book by Simon
Singh -> The Code Book, I hear its good.

Thanks Nizamov for the link, I am really looking forward to join the
class, and since its free, it is totally an asset.

Yes Thijs I have seen this book, and since its such a big book, I am
avoiding it right now but I really liked the author's style when I
read his book on python language.

Thanks Visgean, the links seem really valuable

Thanking all
with regards

Chetan H Harjani
IIT Delhi
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Algorithms in Python

2012-01-26 Thread Chetan Harjani
On Thu, Jan 26, 2012 at 2:22 AM, Martin Schöön  wrote:
> On 2012-01-25, Chetan Harjani  wrote:
>> Thanks Alec for the link. U know I wanted to read this book by Simon
>> Singh -> The Code Book, I hear its good.
>>
> It indeed is. I only remember one error, an error every Scandinavian
> would have spotted.
>
> His book on Fermat's theorem is even better.

I have read the Fermat's theorem, it is really good.


-- 
Chetan H Harjani
IIT Delhi
-- 
http://mail.python.org/mailman/listinfo/python-list


what happens inside?

2011-06-22 Thread Chetan Harjani
why tuples are immutable whereas list are mutable?
why when we do x=y where y is a list and then change a element in x, y
changes too( but the same is not the case when we change the whole value in
x ), whereas, in tuples when we change x, y is not affected and also we cant
change each individual element in tuple. Someone please clarify.

-- 
echo "Impossible" | cat > /dev/null
-- 
http://mail.python.org/mailman/listinfo/python-list


Interpreting Left to right?

2011-06-23 Thread Chetan Harjani
x=y="some string"
And we know that python interprets from left to right. so why it doesnt
raise a name error here saying name 'y' is not defined?

another example:
(1,2) + 3,
here, python raises a  TypeError "can only concatenate tuple(not int) to
tuple" but we know (3,) is a tuple as seen by following:
t=3,
type(t)

Arent both of this contradicting?

-- 
Chetan H Harjani
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Interpreting Left to right?

2011-06-24 Thread Chetan Harjani
Now its all clear. Thanks
@ethan .. ur example is really scary.
I didnt understand ur example fully although.
See this is what i take it as:
x=x['huh']={}

>first python checks check that there are two = operators.
>so it evaluates the RHS(since for = it is RHS to LHS) experession of right
most (why is that?)
>now it assigns that experrsion({...}) to x the left most as u said first
RHS to LHS then LHS to RHS.
>then it assigns x to to x['huh'].
huh!!, ryt?
may be it doesnt make sense but i guess this is the only way to actually not
raise an error.

Where am I wrong?





On Fri, Jun 24, 2011 at 10:02 AM, Chetan Harjani
wrote:

> x=y="some string"
> And we know that python interprets from left to right. so why it doesnt
> raise a name error here saying name 'y' is not defined?
>
> another example:
> (1,2) + 3,
> here, python raises a  TypeError "can only concatenate tuple(not int) to
> tuple" but we know (3,) is a tuple as seen by following:
> t=3,
> type(t)
> 
> Arent both of this contradicting?
>
> --
> Chetan H Harjani
>
>


-- 
Chetan H Harjani
-- 
http://mail.python.org/mailman/listinfo/python-list


Learning python reading software source code

2011-08-25 Thread Chetan Harjani
Hello friends,

I have learned the basic syntax of python through the book HOW TO THINK LIKE
A COMPUTER SCIENTIST n by reading first 10-11 chapters of Apress-BEGINNING
PROGRAMMING FROM NOVICE TO PROFESSIONAL.
(btw it was really very boring)

I am looking forward to learn further by understanding source code of
applications built in python. I guess i will begin with reading the source
code of MIRO http://www.getmiro.com/ .

So I am looking for suggestions on how one can understand the code better.
Any specific references I should look in as I stumble upon libraries n
functions while reading or just the python official docs would be enough?

thanking you
-- 
Chetan H Harjani
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Learning python reading software source code

2011-08-26 Thread Chetan Harjani
Thanks Michael :) . I will keep your suggestions in mind.

On Fri, Aug 26, 2011 at 9:01 AM, Chetan Harjani wrote:

> Hello friends,
>
> I have learned the basic syntax of python through the book HOW TO THINK
> LIKE A COMPUTER SCIENTIST n by reading first 10-11 chapters of
> Apress-BEGINNING PROGRAMMING FROM NOVICE TO PROFESSIONAL.
> (btw it was really very boring)
>
> I am looking forward to learn further by understanding source code of
> applications built in python. I guess i will begin with reading the source
> code of MIRO http://www.getmiro.com/ .
>
> So I am looking for suggestions on how one can understand the code better.
> Any specific references I should look in as I stumble upon libraries n
> functions while reading or just the python official docs would be enough?
>
> thanking you
> --
> Chetan H Harjani
>
>
>


-- 
Chetan H Harjani
-- 
http://mail.python.org/mailman/listinfo/python-list